Octopress Assign Tag
A more powerful assign liquid tag. Features:
- Conditional assignment
- Ternary assignment
- Support for
||
,||=
and+=
Installation
Add this line to your application's Gemfile:
gem 'octopress-assign-tag'
And then execute:
$ bundle
Or install it yourself as:
$ gem install octopress-assign-tag
Next add it to your gems list in Jekyll's _config.yml
gems:
- octopress-assign-tag
Usage
Use the assign tag like normal.
{% assign var1 = 'awesome' %} //=> 'awesome'
{% assign var2 = var1 | upcase %} //=> 'AWESOME'
Conditionally assign variables.
{% assign linkpost = true if post.external-url %}
{% assign comments = true unless post.comments == false %}
{% assign url (post ? post.url : page.url) %}
Use fancy operators in assignment.
{% assign author = post.author || page.author || site.author %}
{% assign name ||= site.name %}
{% assign title_text += ' →' if linkpost %}
Contributing
- Fork it ( https://github.com/octopress/assign-tag/fork )
- 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 a new Pull Request