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 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),