This gem includes list of useful Liquid blocks, tags and filters which can be all embedded in both Wagon and the LocomotiveCMS engine. Behind the scene, it uses Solid to write reliable and consistant liquid code.
For now, it only works best with the edge versions of Wagon and the engine (master branch).
Send an email directly from a liquid template. Although, it does break the MVC pattern, it is reasonable to use it within a LocomotiveCMS site for simple needs.
The emails are sent by Pony. It is disabled in Wagon, only the logs are output.
By default, email sending is html-formatted. You can disable this behaviour by setting the html attribute to false.
The code inside {% sendemail %} and {% endsendemail %} serves as the body of the email. You can access the whole context of your page within the body.
{% if post? and params.email != '' %}
<p>Email sent to {{ params.email }}</p>
{% send_email to: params.email, from: '[email protected]', subject: 'Hello world', page_handle: 'email-template', smtp_address: 'smtp.example.com', smtp_user_name: 'user', smtp_password: 'password' %}
Hello {{ send_email.to }},
Lorem ipsum....
{% endsend_email %}
{% else %}
....
{% endif}
Note: In order to set up the smtp server in Pony, use the smtp_**** attributes.
If you want to use a page as the template for the email, use the page_handle property which is the handle of your page.
{% send_email to: params.email, from: '[email protected]', subject: 'Hello world', page_handle: 'email-template', smtp_address: 'smtp.example.com', smtp_user_name: 'user', smtp_password: 'password' %}{% endsend_email %}
Create a new entry for any content types of the current site. Again, it does break the MVC pattern, so use it wisely.
{% create 'projects', title: 'Your new title' %}
<p>The project {{ project.title }} was created with success</p>
{% else %}
<p>Arrggh, there was an error.</p>
{% endupdate %}
Note: The whole context of the page is available in the 2 blocks.
Update the attributes of a content entry. Again, it does break the MVC pattern, so use it wisely.
{% update project, title: 'Your new title' %}
<p>The project gets updated with success</p>
{% else %}
<p>Arrggh, there was an error.</p>
{% endupdate %}
Note: The whole context of the page is available in the 2 blocks.
In your Wagon site, add the following line to your Gemfile:
group :misc do
gem 'locomotivecms_liquid_extensions', github: 'locomotivecms/liquid_extensions'
end
In the Gemfile of your engine, add the following line:
gem 'locomotivecms_liquid_extensions', github: 'locomotivecms/liquid_extensions'
First, get the source
$ git clone git://github.com/locomotivecms/liquid_extensions.git
$ cd liquid_extensions
Note: Again, if you want to contribute, you may consider to fork it instead
$ bundle install
Run the tests suite
$ bundle exec rake spec
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Feel free to contact me at did at locomotivecms dot com.
Copyright (c) 2013 NoCoffee, released under the MIT license