The view template had Textile in it and I did not notice because the markup for <h2>
is similar (h2.
vs. %h2
). Including gem 'haml_rails'
in the plugin's Gemfile
is sufficient with no extra code.
Use Haml files in Redmine plugin
-
28-09-2022 - |
Question
I am creating a Redmine plugin and would like to use Haml for the view templates. There is an existing plugin which has Haml views (ekanban) and it does not contain any special code to get Haml working other then having you add require 'haml'
to your main application's Gemfile
.
So here is what happens -- the templating system loads the .html.haml
file correctly but renders the HAML markup (like it was rendering ERB).
I've tried to insert the require 'haml'
at various intervals to no avail. I've even tried manually trying to activate Haml.init_rails(...)
as suggested in this SO question. I've tried inserting that in a few places, tried it in a Rails.configuration.to_prepare
block in the plugins' init.rb
file. I've tried telling the Gemfile to not require 'haml'
and attempting to do it during plugin load to no avail. What gives?
Solution
OTHER TIPS
Read carefully Installation instruction for this gem :)
Add "gem 'haml'" to your #{RAILS_ROOT}/Gemfile
I can't agree with this strategy: plugin can't change Redmine core! Any Redmine plugin can have own gems (defined in own Gemfile
) - so I think you can create Gemfile
in your plugin, run bundle install
from the Redmine root and I believe you will manage to use Haml