module Tandem module PagesHelper include ContentsHelper def self.included(base) Tandem::Content.subclasses.each do |klass| # tandem_#{klass.simple_type}_tag is provided as an alias of tandem_content_tag, # specifying the type of content through the method name. For example: # # <%= tandem_image_tag(:test_image) %> # # is equivalent to: # # <%= tandem_content_tag(:test_image, :image) %> # base.send(:define_method, "tandem_#{klass.simple_type}_tag") do |identifier, options = {}, html_options = {}| tandem_content_tag identifier, klass.simple_type, options, html_options end end end # tandem_content_tag creates an HTML DIV element with id and class parameters that # relate to the specified Tandem Content object and contains an internal content element. # If a Tandem::Content record doesn't exist for the unique combination of: # request_key, identifier and type, one will be created automatically. For example: # # <%= tandem_content_tag(:test_image, :image) %> # # would find_or_create a Tandem::Content::Image object and produce the following HTML: # #
... # # If the user is authorized to update content then an edit link will be generated in # conjunction with the content. For example: # # <%= tandem_content_tag(:test_text, :text) %> # # would produce the following HTML (assuming `can? :update, tandem_content` => true): # #
#
# Edit #
# .... #
# # If a user specifies link information for the corresponding Tandem::Content object, # then an A HTML element will be generated surrounding the content. For example: # # <%= tandem_content_tag(:test_image, :image) %> # # produces (assuming that tandem_content.link? => true): # #
# ... # #
# # tandem_content_tag accepts a hash of html_options, which will be converted to # additional HTML attributes of the generated container div. If you specify a :class value, it will be combined # with the default class name for your object. For example: # # <%= tandem_content_tag(:test_image, :image, {}, :class => "bar", :style => 'display:none') %>... # # produces: # #