class Erbse::BlockFilter

Public Instance Methods

on_capture_block(code, content_ast) click to toggle source

assign all code in the block to new local output buffer without outputting it. handles <%@ do %>

# File lib/erbse.rb, line 23
def on_capture_block(code, content_ast)
  [:multi,
    [:block, code, # var = capture do
      [:capture, unique_name, compile(content_ast)]
    ]
  ]
end
on_erb_block(code, content_ast) click to toggle source

Highly inspired by github.com/slim-template/slim/blob/master/lib/slim/controls.rb#on_slim_output

# File lib/erbse.rb, line 7
def on_erb_block(code, content_ast)
  # this is for <%= do %>
  outter_i = unique_name
  inner_i  = unique_name

  # this still needs the Temple::Filters::ControlFlow run-through.
  [:multi,
    [:block, "#{outter_i} = #{code}",
      [:capture, inner_i, compile(content_ast)]
    ],
    [:dynamic, outter_i] # return the outter buffer. # DISCUSS: why do we need that, again?
  ]
end