New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to pass options to sub-template processor? #192
Comments
@sunaku: Good point! There is currently no syntax to set options for embedded engines. Which option do you need to set? Do you have a syntax proposal? |
I want to set the following Redcarpet options:
I think the best place to set these would be when we tell Tilt our preferences: Tilt.prefer Tilt::RedcarpetTemplate, my_options_hash Thanks. |
I found a workaround to the issue. In fact, perhaps this is how Tilt is meant to be used:
This is using Redcarpet 2.0.0b5, by the way. |
Tilt's template engine lookup is separate from template initialization, so this is probably something that Slim should provide. Camping solves this problem by having a per-app options-hash where you can set it: Camping.goes :Foo
Foo.set :markdown, { :fenced_code_blocks => true } Sinatra does the same. |
Fixed in master. Slim::EmbeddedEngine.set_default_options :markdown => {:fenced_code_blocks => true} This needs to be documented. @judofyr: Any ideas how to make such things on a per app-basis, not on a per-ruby-instance basis? This is a Temple thing. |
Sorry for the late reply @minad but that snippet doesn't work:
Could you please tell me how to make it work with Slim 1.3.6? 😅 |
Never mind. I found the answer in issue #245. 😤 Tilt.prefer Tilt::RedcarpetTemplate::Redcarpet2, 'markdown' By adding the above line, we ensure that Slim uses Redcarpet (for which the
Cheers! |
I learned recently that Redcarpet has_two_ sets of options. See my blog post for details and an updated solution. 🍰 |
Hello,
I use
markdown:
sub-templates inside my Slim templates. I was able to make Slim use Redcarpet for markdown processing via the Tilt API, as shown below. However, I don't know how to set default rendering options for Redcarpet, which is hidden somewhere in the Slim => Tilt pipeline. In particular, I want to enable GitHub-style code blocks and also use Albino/Pygments for syntax highlighting of code blocks.I tried RTFM and browsing the Tilt & Temple source code, but no luck. So I ask you now for suggestions.
The above code yields:
But eventually (after I set my rendering options), I want to get something like this:
I'm using ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] with slim (1.0.3), tilt (1.3.3), and redcarpet (1.17.2).
Thanks for your consideration.
The text was updated successfully, but these errors were encountered: