Class: Slim::EmbeddedEngine::TiltEngine Private
- Inherits:
-
Slim::EmbeddedEngine
- Object
- Temple::Filter
- Filter
- Slim::EmbeddedEngine
- Slim::EmbeddedEngine::TiltEngine
- Defined in:
- lib/slim/embedded_engine.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- COLLECT_LOCALS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Code to collect local variables
%q{eval('{' + local_variables.select {|v| v[0] != ?_ }.map {|v| ":#{v}=>#{v}" }.join(',') + '}')}
Instance Method Summary collapse
Methods inherited from Slim::EmbeddedEngine
Methods inherited from Filter
#on_slim_attrs, #on_slim_control, #on_slim_output, #on_slim_tag, #tmp_var
Instance Method Details
#on_slim_embedded(engine, *body) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/slim/embedded_engine.rb', line 35 def (engine, *body) text = collect_text(body) engine = Tilt[engine] if [:precompiled] # Wrap precompiled code in proc, local variables from out the proc are accessible # WARNING: This is a bit of a hack. Tilt::Engine#precompiled is protected precompiled = engine.new { text }.send(:precompiled, {}).first [:dynamic, "proc { #{precompiled} }.call"] elsif [:dynamic] # Fully dynamic evaluation of the template during runtime (Slow and uncached) [:dynamic, "#{engine.name}.new { #{text.inspect} }.render(self, #{COLLECT_LOCALS})"] elsif [:interpolate] # Static template with interpolated ruby code [:slim, :text, engine.new { text }.render] else # Static template [:static, engine.new { text }.render] end end |