Module: AxTags

Defined in:
lib/axtags/ax_parser.rb,
lib/axtags.rb,
lib/axtags/ax_context.rb,
lib/axtags/tag_library.rb

Overview

AX TAGS Flexible, extensible custom tag and template-parsing framework built around the Radius templating framework.

TagLibrary - Composed of an AxContext and an AxParser, each library class provides the direct interface for defining tags in a given context, passing local variables to the parser, and managing the parsing process. Best use calls for the application to create any number of descendant classes of this class in which they define tags and call parsing actions upon. For example:

class MyTagLibrary < AxTags::TagLibrary
  tag "myanchor" do |t|
    "<a class='awesome_anchor' href='http://awesometown.com/'>I am Awesome!</a>"
  end
end

MyTagLibrary.parse("Here is an awesome link: <ax:myanchor/>")
=> "Here is an awesome link: <a class='awesome_anchor' href='http://awesometown.com/'>I am awesome!</a>"

Because tags are defined at a class level, it's not generally recommended to use the parent class as your API to tag definition and parsing, though it is possible to access the context and parsers directly and define tags and call parsing on them. That would look some like this:

AxTags::TagLibrary.context.with do |c|
 c.define_tag "myanchor" do |t|
   "<a class='awesome_anchor' href='http://awesometown.com/'>I am Awesome!</a>"
 end
end
AxTags::TagLibrary.parse("Here is an awesome link: <ax:myanchor/>")
=> "Here is an awesome link: <a class='awesome_anchor' href='http://awesometown.com/'>I am awesome!</a>"

This introduces the complication of having only one global tag library in which all tags in your system would exist, which is why the first example is the preferred method for optimal extensibility and namespacing.

Defined Under Namespace

Classes: AxContext, AxParser, TagLibrary

Class Method Summary collapse

Class Method Details

.versionObject



15
16
17
# File 'lib/axtags.rb', line 15

def self.version
  Gem.loaded_specs["axtags"].version.to_s
end