Class: LiquidAssets::TinyLiquid

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid_assets/tiny_liquid.rb

Class Method Summary collapse

Class Method Details

.compile(source, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/liquid_assets/tiny_liquid.rb', line 10

def compile(source, options = {})
    ns = ::LiquidAssets::Config.namespace
    js = context.eval("TinyLiquid.parse(#{source.inspect},{namespace:'#{Config.namespace}'}).code")
    <<-TEMPLATE
       function(locals,filters){
           var $_tmpbuf, $_html = #{ns}._FNS.html, $_err = #{ns}._FNS.err,
               $_rethrow=#{ns}._FNS.rethrow, $_merge=#{ns}._FNS.merge,
               $_range=#{ns}._FNS.range, $_array=#{ns}._FNS.array;
               #{js}
               return $_buf;
      }
    TEMPLATE
end