Skip to content

octopress/assign-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7555673 · Jun 28, 2018

History

9 Commits
May 14, 2015
Jun 28, 2018
May 14, 2015
Apr 20, 2015
May 14, 2015
Feb 23, 2015
Jul 18, 2014
Jan 12, 2015
Jul 18, 2014
May 14, 2015

Repository files navigation

Octopress Assign Tag

A more powerful assign liquid tag. Features:

  • Conditional assignment
  • Ternary assignment
  • Support for ||, ||= and +=

Build Status Gem Version License

Installation

If you're using bundler add this gem to your site's Gemfile in the :jekyll_plugins group:

group :jekyll_plugins do
  gem 'octopress-assign-tag'
end

Then install the gem with Bundler

$ bundle

To install manually without bundler:

$ gem install octopress-assign-tag

Then add the gem to your Jekyll configuration.

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

  1. Fork it ( https://github.com/octopress/assign-tag/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

A more powerful assign liquid tag.

Resources

License

Stars

Watchers

Forks

Packages

No packages published