to_liquid error for ActionController::CgiRequest

6 views
Skip to first unread message

ben

unread,
Feb 13, 2007, 5:34:49 PM2/13/07
to Liquid Templates
I'm trying to use liquid with the themes plugin and am just doing the
simple example:

<link rel="StyleSheet" href="{% themeitem %} default.css {%
endthemeitem %}" />

Which generates:

<link rel="StyleSheet" href="Liquid error: undefined method
`to_liquid' for #<ActionController::CgiRequest:0x320ab2c>" />

I'm not sure how/where to add the to_liquid method to CgiRequest (or
if that's even the solution).

This is the "themeitem" code:

# A Liquid Tag for retrieving path information for theme specific
media
#
# Returns the path based on the file extension
#
class Themeitem < Liquid::Block

@@image_exts = %w( .png .jpg .jpeg .jpe .gif )
@@stylesheet_exts = %w( .css )
@@javascript_exts = %w( .js .htc )

def render(context)
# Which, if either, of these are correct?
base_url = context['request'].relative_url_root ||
ActionController::Base.asset_host.to_s
theme_name = @theme_name || context['active_theme']

filename = @nodelist.join('').strip
ext = File.extname( filename )

if @@image_exts.include?( ext )
"#{base_url}/themes/#{theme_name}/images/#{filename}"

elsif @@stylesheet_exts.include?( ext )
"#{base_url}/themes/#{theme_name}/stylesheets/#{filename}"

elsif @@javascript_exts.include?( ext )
"#{base_url}/themes/#{theme_name}/javascript/#{filename}"
end
end
end

Liquid::Template.register_tag( 'themeitem', Themeitem )

Reply all
Reply to author
Forward
0 new messages