Skip to content

Commit

Permalink
fix: auto-recompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRiedler committed Dec 16, 2024
1 parent 7b4c6d6 commit 8224c07
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions lib/handlebars_assets/handlebars_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def initialize(options = {})
def call(input)
renderer = HandlebarsRenderer.new(path: input[:filename])
engine = renderer.choose_engine(input[:data])
renderer.compile(engine.render)
rendered = renderer.compile(engine.render)
{ data: rendered, metadata: { dependencies: [input[:filename]] } }
end
end

Expand Down Expand Up @@ -91,12 +92,13 @@ def compile(source)

# handle the case of multiple frameworks combined with ember
# DEFER: use extension setup for ember
if (HandlebarsAssets::Config.multiple_frameworks? && @template_path.ember?) ||
(HandlebarsAssets::Config.ember? && !HandlebarsAssets::Config.multiple_frameworks?)
compile_ember(trim_source)
else
compile_default(trim_source)
end
data =
if (HandlebarsAssets::Config.multiple_frameworks? && @template_path.ember?) ||
(HandlebarsAssets::Config.ember? && !HandlebarsAssets::Config.multiple_frameworks?)
compile_ember(trim_source)
else
compile_default(trim_source)
end
end

def compile_ember(source)
Expand Down
2 changes: 1 addition & 1 deletion test/handlebars_assets/hamlbars_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_render_haml
scope = make_scope root, file
source = '%p This is {{handlebars}}'

rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)
rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)[:data]

assert_equal hbs_compiled('test_render', compile_haml(source)), rendered
end
Expand Down
2 changes: 1 addition & 1 deletion test/handlebars_assets/handlebars_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def teardown
end

def render_it(scope, source)
HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)
HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)[:data]
end
end
end
2 changes: 1 addition & 1 deletion test/handlebars_assets/slimbars_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_render_slim
scope = make_scope root, file
source = 'p This is {{handlebars}}'

rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)
rendered = HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)[:data]

assert_equal hbs_compiled('test_render', compile_slim(source)), rendered
end
Expand Down

0 comments on commit 8224c07

Please sign in to comment.