Skip to content

Accessing Assets Helpers From Templates #150

@ayanko

Description

@ayanko

Hello.

That's about using

  • asset_path
  • image_path
  • image_tag
  • and friends

After upgrade to latest version (4.2.6) and handlebars_assets(0.23.0) sprockets don't want anymore to compile templates like:

.wrapper
  .illustration
    = image_tag('rails.png')

That's because we don't pass context anymore for new transformer.

There is easy solution:

module HandlebarsAssets
  class HandlebarsProcessor
    def call(input)
      renderer = HandlebarsRenderer.new(path: input[:filename])
      engine = renderer.choose_engine(input[:data])
      context = input[:environment].context_class.new(input)
      renderer.compile(engine.render(context))
    end
  end
end

P.S. Sorry I don't have time to create PR ..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions