Using raedsheet_link_tag and javascript_include_tag styles in Liquid Drop

I want users to be able to fully control and edit the layout. I also want them to be able to include the javascript plugins they want. So I had to make an interface to let them do it.

For example, html by default looks like a more complex version:

<head>
  <title>{{site.name}}</title>
  ...
  {{js_plugins.colorbox}} # this should return the necessary javascript and/or stylesheet tags
</head>

My liquid JsPlugins drop is as follows:

class JsPluginsDrop < Liquid::Drop
  include ActionView::Helpers::AssetTagHelper
  ...
  def colorbox
    javascript_include_tag "/path/to/js"
  end
end

When I run my specifications, I get this error (note that you see @drop["colorbox-1.3.15"]when the code above acts differently. However, I wanted to simplify my code, since this is not a problem, this is use TagHelper, which is a problem):

Failures:
  1) JsPluginsDrop colorbox-1.3.15 should return the correct script tags
     Failure/Error: @drop["colorbox-1.3.15"].stylesheets.should include("/jquery-plugins/colorbox-1.3.15/example1/colorbox.css")
     undefined local variable or method `config' for #<JsPluginsDrop:0xcbfab38>
     # ./app/drops/js_plugins_drop.rb:22:in `stylesheets'
     # ./spec/models/js_plugins_drop_spec.rb:11

, , Rails, config Rails. :cache => true, , , stylesheet_link_tag javascript_include_tag drop, ?

+5
1

, , :

class MyDrop < Liquid::Drop

  ...
  def my_js_tag
    helpers.javascript_include_tag '/some/thing'
  end
  ...

  def helpers
    @helpers ||= ActionController::Base.helpers
  end

end
+2

All Articles