Module: Alula::LiquidExt

Included in:
Block, Tag
Defined in:
lib/alula/core_ext/tag.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/alula/core_ext/tag.rb', line 6

def context
  @context
end

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/alula/core_ext/tag.rb', line 8

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#initialize(tagname, markup, tokens) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/alula/core_ext/tag.rb', line 18

def initialize(tagname, markup, tokens)
  super
  
  @tagname = tagname
  @markup = markup.strip
  @tokens = tokens
  
  @info = {}
  @options = {}
  
  # Parse tag options
  if m = /^([\"][\S\. ]+?[\"]|[\S\.]+)(.*)$/.match(@markup)
    @source = m[1].gsub(/^["]?([^"]+)["]?$/, '\1')
    @source = "" if @source == '""'
    @options["source"] = @source unless @source.empty?

    if m[2]
      m[2].scan(/(\S+?):["]?((?:.(?!["]?\s+(?:\S+):|[>"]))+.)["]?/) do |name, value|
        @options[name] = value.strip
      end
    end
  end
  
  prepare if respond_to?("prepare")
end

#render(context) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/alula/core_ext/tag.rb', line 44

def render(context)
  @context = context
  if respond_to?("content")
    content
  else
    super
  end
end