# LiquidMarkdown Combines [Liquid](https://github.com/Shopify/liquid) and [Markdown](https://daringfireball.net/projects/markdown/) templating for generic templating and Rails Mailers. ## Installation Add this line to your application's Gemfile: ```ruby gem 'liquid_markdown' ``` And then execute: $ bundle Or install it yourself as: $ gem install liquid_markdown ## Usage You can use `liquid_markdown` in your mailer with `.liqmd` file extension ```ruby # app/mailers/user_mailer.rb class UserMailer < ApplicationMailer def welcome(user) @user = user @lmVariables = @user.values mail(to: @user.email, subject: 'liquid markdown layout') do |format| format.html format.text end end end # app/views/user_mailer/welcome.liqmd # Hello Admin Below are the list of products that you purchased Thanks ------ ABC XYZ ``` We can compile Liquid templates manually using `html` to convert into html format and `text` to convert into plain text. ```ruby lm = LiquidMarkdown::Render.new("Hello {{user.profile.name}}!", {user: {profile: {name: 'Bob'}}}) lm.html # => "

Hello Bob!

" lm.text # => "Hello Bob!" ``` ```ruby lm = LiquidMarkdown::Render.new("# my first heading") lm.html # => "

my first heading

" lm.text # => "my first heading" ``` We can combine both Liquid and Markdown together, Liquid will get compiled first and then Markdown will get compiled ```ruby lm = LiquidMarkdown::Render.new("# Hello {{username | upcase}}", {username: 'Admin'}) lm.html # => "

Hello ADMIN

" lm.text # => "Hello ADMIN" ``` ## Depricated (need to remove this) We can also setup layout options to wrap result within that layout. use `{{yield}}` block in your template where we can render output. ```ruby lm = LiquidMarkdown::Render.new("# Hello {{username | upcase}}", {username: 'Admin'}) lm.layout = "{{yield}}" lm.html # => "

Hello ADMIN

" ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/buzzware/liquid_markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).