Created
June 16, 2009 20:40
-
-
Save julesfern/130884 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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