|
index > template
Template defines outline of HTML file for juli documents.
(NOTE: Please don't be confused with template(macro), which is a macro (command, or directive) to specify which template here is used for each document.)
Template in Juli follows ERB format, where ERB is a HTML file with ruby script in <%= ... %> and/or <% ... %> tag. Any ruby script can be written in the tag.
Helper is a ruby method which can be used in template file.
Juli supports two kind of helpers. One is standard helper, which has been already provided by juli. The other is custom helper.
Followings are standard helper in alphabetical order. You can use them in your template.
body: | generated html from juli text page |
fb_like: | Facebook 'Like!' button (>= v1.12) |
fb_comments: | Facebook 'Comments' entry (>= v1.12) |
javascript: | javascript url |
prototype: | prototype url |
stylesheet: | stylesheet url |
title: | HTML title |
Details of these are described below.
HTML main part generated from juli text page
You can place 'Like!' button in the template as you like.
The following one-shot setup is required.
Note: this setup section is for both fb_like and fb_comments.
<html xmlns:fb="http://ogp.me/ns/fb#">
Where, YOUR_APPID above should be replaced to your own application ID for your site which can be taken at https://developers.facebook.com/apps .<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=YOUR_APPID"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>
If your Juli site URL prefix is http://a.b.com/juli , and you need both facebook 'Like!' button and 'comments' field, template is like this:
<html xmlns:fb="http://ogp.me/ns/fb#"> <head> : : </head> <body> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=123456789"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> : : <%= body %> : : <%= fb_like %> <%= fb_comments %> </body> </html>
Again, appId 123456789 in the above example is JUST example. You SHOULD replace 123456789 in the above example to your actual APP_ID.
.juli/config is like this:
output_top: ... : : url_prefix: 'http://a.b.com/juli' facebook: like: template: '<fb:like href="%{href}" send="false" layout="button_count" width="450" show_faces="false"></fb:like>' comments: template: '<fb:comments href="%{href}" num_posts="2" width="470"></fb:comments>'
See lib/juli/template/facebook.html as an example. Compare it with default.html for the difference.
Facebook 'Like!' href looks optional while 'comments' href looks required according to 'href' attributes description in both documents below:
I am not sure comments href is really required or optional. If both href are optional and you are OK to set href to the current page, then it is simpler to use facebook tag directly than using Juli facebook helper.
For now, in juli, I assume facebook 'comments' href is required.
Facebook 'Comments' entry. See fb_like description for the detailed setup. Also, see lib/juli/template/facebook.html as an example.
javascript url
prototype url
stylesheet url
HTML title
Custom helper can be added. Please read rdoc in lib/juli/visitor/html/helper.rb
In Juli, helper is quite similar to macro. Actually, both ruby script structures are exactly the same, but the purpose is different. Helper is used for template and macro is used in juli wiki page.
Currently, there is no plan to integrate them. If you need, please request me it with the detailed reason via sourceforge page http://sourceforge.net/projects/jjjuli/ -> Tracker -> Feature Request, thank you!
Template files reside as follows: