From 6d757c6cab83804400efd50269623c86f4ac5df2 Mon Sep 17 00:00:00 2001 From: waynedpj Date: Tue, 17 Dec 2013 19:51:14 -0500 Subject: [PATCH 1/2] add example use of {{ . }} added example to show use of list/array element access in Mustache per https://github.com/ruhoh/ruhoh.rb/issues/258#issuecomment-30800179 --- docs/2/pages.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/2/pages.md b/docs/2/pages.md index c2b86b8..172d280 100644 --- a/docs/2/pages.md +++ b/docs/2/pages.md @@ -514,6 +514,18 @@ Above, we've set special attributes `icon` and `days` which are now availble: +Now we can access these attributes with the following Mustache tags: + +{{#raw_code}} +

{{ page.title }}

+ +

It will be sunny on the following days:

+ +{{/raw_code}} ## page.content From 06072532db2c2301e67436bddafb099662d64c34 Mon Sep 17 00:00:00 2001 From: waynedpj Date: Tue, 31 Dec 2013 15:02:37 -0500 Subject: [PATCH 2/2] show how to add plugin Block Helpers to MasterView see https://github.com/ruhoh/ruhoh.rb/issues/259 --- docs/2/plugins.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/2/plugins.md b/docs/2/plugins.md index 6254a43..745e316 100644 --- a/docs/2/plugins.md +++ b/docs/2/plugins.md @@ -112,13 +112,20 @@ A mustache block helper is a method that acts on the encapsulated block of conte Here we are calling the method `raw_code` which will be passed the block content as its argument: - def raw_code(sub_context) - code = sub_context.gsub('{', '{').gsub('}', '}').gsub('<', '<').gsub('>', '>') - "
#{code}
" + module MasterViewAddons + def raw_code(sub_context) + code = sub_context.gsub('{', '{').gsub('}', '}').gsub('<', '<').gsub('>', '>') + "
#{code}
" + end end + + # now make add the plugin globally available + Ruhoh::Views::MasterView.send(:include, MasterViewAddons) Block helpers should return a String. +For more information see the [2.x View Helper Plugins upgrade instructions](http://ruhoh.com/docs/2/upgrading/#toc_17). + ## Contextual Helpers A mustache contextual helper is a special kind of block helper that acts on a given context (a data-structure),