Created
January 3, 2012 23:36
-
-
Save wojtekmach/1557585 to your computer and use it in GitHub Desktop.
Slim + handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tilt | |
class HandlebarsSlimTemplate < ::Slim::Template; end | |
register HandlebarsSlimTemplate, :handlebars_slim | |
end | |
class Slim::EmbeddedEngine | |
register :handlebars, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" } | |
register :handlebars_slim, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" }, engine: StaticTiltEngine | |
end |
@SergXIIIth You just need to include it in an initializer file (/config/initializers/slim.rb
for example), then you will be able to use the handlebars:
tag in your slim files.
I'm assuming something changed with slim, but now Slim::EmbeddedEngine
doesn't work anymore. I had to do just Slim::Embedded
instead.
class Slim::Embedded
register :handlebars, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" }
register :handlebars_slim, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" }, engine: StaticTiltEngine
end
https://github.com/slim-template/slim/blob/master/lib/slim/embedded.rb#L63
@wojtekmach Could you provide a sample, template example? How can I give an id to embedded code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for Gist. Could you also share how to integrate it into Rails and show Rails view example. Thank you very much