sprockets - Rails, won't allow stylesheets with custom extension in pipeline handled through local gem -
How can I pre-process CSS files via a gem with a custom extension?
I have searched for hours to find this, but have not come close to the solution. I have seen less, SASS, coffee script, amber gems to get better ideas, but their way of dealing with them neither works for me.
Mani rail code extension for custom styling sheets to ignore any setting, using the gem to handle custom stylesheets, and simply stylesheet.css .custom
tag to stylesheet.css.custom.css
returns a 404 error.
I have tried a lot, but I hope this code tells me what I am doing:
# lib / custom-rails .rb Config.app_generators.stylesheet_engine =: custom #lib / custom-rail Rb config.before_initialize do App | Spochet :: Engine autoloading #Sprockets.register_engine '.custom', Custom Template End # BB / custom / custom_timpler RB ActiveSupport.on_load (: Action_View) ActionView: Template.register_template_handler :: Custom, Custom :: Rail :: Customized Plate End
I am using Rail 4.0.1.
Any ideas how can I get Mani in handling stylesheets? Thanks!
I finally had to do this work.
Key After an Initializer 'custom-rails.sprockets_engine': 'sprockets.environment', group :: do all | App | App.assets.register_engine '.custom', customerhepplete and
Here is the last code for those who find themselves in a similar situation. I have also added the Tilt Template to make it work well.
custom / custom_template.rb 'tilt' module requires custom module class custom template & lt; :: Tilt :: Template self.default_mime_type = 'text / css' def Def Def Definition (scope, local, and block) # Processing allows DEF to decrypt? End of end of false end # Lib / Custom / Engine RB module custom module class engine engine and LT; :: Rail :: Engine initialization 'custom-rail.procates_engine', followed by: 'sprockets.environment', group :: all | App | App.assets.register_engine '.custom', Customer Templates & End # Lib / Custom / Template_Handler RB module custom module guardrail class templatehandler DEF self.erb_handler @@ erb_handler || = ActionView :: Template.registered_template_handler (: erb) end def Self.call (template) compiled_source = erb_handler.call (template) #Support end end end code to ActiveSupport.on_load (action_view) ActionView :: Template.register_template_handler :: Custom, Custom :: Rail :: TemplateHandler End The first step of debugging was to . Custom
extensions were not handled properly I could see that they were not handled properly because CSS assets
uri instead of stylesheet
uri.
Comments
Post a Comment