Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi team,
How I can provide template_dir in render_file method? This snippet doesn't seem to work. Asciidoctor.render_file(m[0], :in_place => true, :safe =>10, 'template-dir' => '~/projects/asciidoctor-backends/haml/deckjs', #:to_file=>'slides.html', :attributes => { 'source-highlighter' => 'highlightjs' }) } Please advice... |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
|
Hey Victor! Here you go. This snippet should get you going:```ruby require 'asciidoctor' I'm grabbing the source file from the first argument to my Ruby script, but of course you can plug m[0] back in there.source_file = ARGV.first Asciidoctor.render_file(source_file, :in_place => true, :safe => :safe, :template_dir => "#{ENV['HOME']}/projects/asciidoctor/asciidoctor-backends", :template_engine => 'haml', :backend => 'deckjs', :attributes => %w(source-highlighter=highlight.js) ) ```
I'll point out a few things to help you understand what's needed fixing. :template_dir :: The template directory should be specified as an option argument, a hash symbol adjacent to other options like :safe, :backend and :attributes. The directory can be a relative path to from the working directory of the script or an absolute path. The ~ in the path is not expanded, so you need to use the Ruby environment variable syntax #{ENV['HOME']} to resolve it explicitly. Note that symbols in Ruby can't have a hyphen (without quoting it) so when we are doing options, we always use underscore. Notice that I left the "haml/deckjs" off of the template directory path. I split it out into the :template_engine and :backend options. From that, Asciidoctor will resolve the final directory path to the template directory. This makes it possible to switch between engines and backends without fiddling with the path. :template_engine :: This option is nothing more than a hint to Asciidoctor to tell it how to build the full path to the templates. :backend :: This serves as a hint to Asciidoctor to tell it how to build the full path to the templates, plus it makes the parser and renderers aware of what output is being targeted (in this case an HTML 5 dialect). :attributes :: Attributes can now be specified as a String (in the same form as name=value pairs are used on the commandline) or as an Array of name=value pairs. The %w() quoting automatically creates an Array from a space-separated list. It's my preferred way of defining attributes. :safe :: The safe-mode can be specified as a symbol. This makes it clearer and more future proof than using the internal numeric value. Let me know if you still have trouble making that work, or if you have other questions. Btw, I recommend that you use Asciidoctor 0.1.4.preview.3, which you can install from rubygems.org using: gem install asciidoctor --pre Good luck! On Tue, Aug 20, 2013 at 10:33 PM, gamussa [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi team, ... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
|
In reply to this post by gamussa
I was thinking that we should probably make ~ expansion work in the Asciidoctor API. It seems that when we build the directory to the templates, we don't use File.expand_path in the right place, which handles special path symbols like tilde. Perhaps file an issue? -DanOn Tue, Aug 20, 2013 at 11:12 PM, Dan Allen <[hidden email]> wrote:
... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
In reply to this post by mojavelinux
Hi Dan!
Very fast help! As usual! Everything works like a charm! Now after I've setup (with your help) desk.js backend and guard/livereload scripts, finally I can focus on my J1 preso (written in asciidoc). Small question, are you going this year? Cheers, Vik |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
|
I'm excited to hear it! With that combo, your going to put on a show to remember. I can't wait to see the reactions! As for me, I'm still not sure yet. I have a badge reserved, and I certainly want to be there, but haven't made the call yet. On Tue, Aug 20, 2013 at 11:39 PM, gamussa [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi Dan! ... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |