Module: TextAssetStandardTags

Included in:
Javascript, Stylesheet
Defined in:
app/models/text_asset_standard_tags.rb

Defined Under Namespace

Classes: TagError

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/text_asset_standard_tags.rb', line 5

def self.included(base)
  base.class_eval do
   
    # declares the <r:stylesheet /> OR <r:javascript /> tag depending on the
    # class type of base.
    tag_name = base.name.to_s.underscore
    tag tag_name do |tag|
      if name = tag.attr['name']
        if named_asset = base.find_by_name(name.strip)
          named_asset.render
        else
          raise TagError.new("#{tag_name} with name `#{name}' not found")
        end
      else
        raise TagError.new("`#{tag_name}' tag must contain a `name' attribute.")
      end      
    end

  end
end