module MasterView module Directives #outputs a block around the text tags, if left bracket count is higher than right #assume that the end is a right bracket otherwise use end class GlobalInlineErb < MasterView::DirectiveBase metadata :priority => 'Low', :global_directive? => true, :category => 'erb', :description => 'Inline substitution notation for Erb expressions' def initialize(attribute_value = nil) super(attribute_value) end event :before_stag do element_attrs.each do |key, value| replace_with_erb!( value ) end end def characters(dcs) replace_with_erb!( data ) dcs.render end def replace_with_erb!(value) subs = value.gsub!( MasterView::InlineErbSubstitutionRegex, '<%\1%>' ) end end end end