Module: Rang::Helpers

Extended by:
ActionView::Helpers::JavaScriptHelper
Defined in:
lib/rang/helpers.rb

Class Method Summary collapse

Class Method Details

.templates(context) ⇒ Object

Using ‘context` here is very un-ruby, but it is the cleanest way of accessing the peculiar scope that assets are compiled in.



8
9
10
11
12
13
14
15
# File 'lib/rang/helpers.rb', line 8

def templates(context)
  template_paths(context).each do |path|
    transformed_path = path.sub(/\..*$/, ".html")
    context.depend_on_asset(transformed_path)
    asset = context.environment.find_asset(transformed_path.sub(/\..*$/, ".html"))
    yield transformed_path.sub(/\..*$/, ".html"), escape_javascript(asset.to_s)
  end
end