Skip to content

Instantly share code, notes, and snippets.

@julesfern
Created June 16, 2009 20:40
Show Gist options
  • Select an option

  • Save julesfern/130884 to your computer and use it in GitHub Desktop.

Select an option

Save julesfern/130884 to your computer and use it in GitHub Desktop.
require 'liquid'
module SMIL
module Helper
class AssetTag < ::Liquid::Block
def initialize(tag_name, id, tokens)
super
@asset_id = id
@attributes ||= {}
end
def render(context)
# FIXME I should be using the asset's to_smil method, but it's not done yet...
output = <<-EOF
<asset mock="true" id="#{@asset.id}" #{@attributes.collect{|k,v| "#{k}='#{v.strip}'"}.join(" ")} />
EOF
EventDispatcher.dispatch! :rendered_asset, @asset_id
return output
end
def unknown_tag(name, params, tokens)
@attributes ||= {}
@attributes[name] = params
end
def dispatcher
SMIL::EventDispatcher
end
end
end
end
Liquid::Template.register_tag('asset', SMIL::Helper::AssetTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment