Class: Octopress::Tags::Assign::Tag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Octopress::Tags::Assign::Tag
- Defined in:
- lib/octopress-assign-tag.rb
Constant Summary collapse
- SYNTAX =
/([[:word:]]+)\s*(=|\+=|\|\|=)\s*(.*)\s*/o
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ Tag
constructor
A new instance of Tag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ Tag
Returns a new instance of Tag.
11 12 13 14 |
# File 'lib/octopress-assign-tag.rb', line 11 def initialize(tag_name, markup, tokens) @markup = markup super end |
Instance Method Details
#render(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octopress-assign-tag.rb', line 16 def render(context) return unless markup = TagHelpers::Conditional.parse(@markup, context) if markup =~ SYNTAX var = $1 operator = $2 value = $3 value = TagHelpers::Var.get_value(value, context) return if value.nil? context = TagHelpers::Var.set_var(var, operator, value, context) else raise SyntaxError.new("Syntax Error in 'assign tag': #{@markup} - Valid syntax: assign [var] = [source] | filter") end '' end |