Module: Liquor::Library::ModuleMethods

Defined in:
lib/liquor/library.rb

Instance Method Summary collapse

Instance Method Details

#export(compiler) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'lib/liquor/library.rb', line 13

def export(compiler)
  @functions.each do |function|
    compiler.register_function function
  end

  @tags.each do |tag|
    compiler.register_tag tag
  end
end

#function(name, options = {}, &block) ⇒ Object


23
24
25
# File 'lib/liquor/library.rb', line 23

def function(name, options={}, &block)
  @functions << Function.new(name, options, &block)
end

#function_alias(name, other) ⇒ Object


27
28
29
30
31
32
33
34
# File 'lib/liquor/library.rb', line 27

def function_alias(name, other)
  function = @functions.find { |f| f.name == other }
  if function.nil?
    raise "Cannot alias to function `#{other}', as it does not exist"
  end

  @functions << function.alias(name)
end

#tag(name, options = {}, &block) ⇒ Object


36
37
38
# File 'lib/liquor/library.rb', line 36

def tag(name, options={}, &block)
  @tags << Tag.new(name, options, &block)
end