deface
deface copied to clipboard
Deface precompile fails on HAML partials
Hi,
I was really glad to see the precompile option added to deface. I use deface quite widely for Spree Commerce and the precompile would certainly give a great boost - GREAT JOB Deface Team!
However, recently I've added several haml partials rendered through deface. When I try to precompile it on server using:
bundle exec rake deface:precompile
I got an error:
uninitialized constant Deface::HamlConverter
Do you have any idea how to correct it?
@matfiz it might just be that Deface can't find the haml engine when loading (so it doesn't require the hamlconverter). Can you confirm that haml is required when running the precompile rake?
I'll try testing the same locally.
Any progress on this?
@NathanielWroblewski Not that I know of. Do you have some steps that would reproduce this issue? I could probably take a look at it next week for you.
I'll try to whip something up. Thanks, @radar.
@radar, I'm able to circumvent this by appending the .deface
suffix to my haml partials. I'm not too familiar with this gem though, so I'll try to spin up a simple application that reproduces this error in case there are underlying issues.
I'm seeing another Haml related issue which may be related to this one: #119.
The reason is here https://github.com/spree/deface/blob/master/lib/deface/railtie.rb#L58
haml_converter
required only if deface is enabled by config, but if you want to use deface precompilation you need to disable deface... Paradox
How do other people solve this issue?
For reference this seems to work for me. I just create a deface_precompile.rake file and override the precompile rake task like this:
require 'deface'
# checks if haml is loaded and enables support
if defined?(Haml)
Rails.application.config.deface = Deface::Environment.new
Rails.application.config.deface.haml_support = true
require 'deface/haml_converter'
end
namespace :deface do
desc "Precompiles overrides into template files"
task :precompile => [:environment, :clean] do |t, args|
require "deface/action_view_extensions"
Deface::Precompiler.precompile()
end
end
I solve it with precompile on capistrano deploy by rake task
@arturtr something like this?
namespace :deface do
desc 'Precompile deface templates'
task :precompile do
on roles(:app) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, 'deface:precompile'
end
end
end
end
end
after 'deploy:updated', 'deface:precompile'