Skip to content

can_has_assets is a super-simple way of requiring stylesheets and javascript files from within views.

License

Notifications You must be signed in to change notification settings

radicaled/can_has_assets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CanHasAssets
============

can_has_assets is a super-simple way of requiring stylesheets and javascript files
from within views. It also supports inserting snippets of CSS and Javascript into
a page only once. Snippet support should really only be used for rapid prototyping,
though. :)

Installation
------------

script/plugin install git://github.com/radicaled/can_has_assets.git

Notes
-----

can_has_* will include a file or snippet only once -- it is safe to call these
methods multiple times, where-ever required.

Alternatives
------------

If you're looking for more control, consider Needy Controllers by Michael Bleigh:

http://github.com/mbleigh/needy-controllers/tree


Example
=======

In your layout:

<%= stylesheet_link_tag :can_has_assets %>
<%= javascript_include_tag :can_has_assets %>

In your views:

CSS
---
<% can_has_css 'css_file' %>

<% can_has_css :sample_snippet do %>
.item {
    /* some fake example css here */
}

Javascript
----------
<% can_has_js 'js_file' %>

<% can_has_js :sample_snippet do %>
function helloWorld() {
    alert("Hello, world!");
}
<% end %>


<% end %>
Copyright (c) 2009 Arron Washington, released under the MIT license

About

can_has_assets is a super-simple way of requiring stylesheets and javascript files from within views.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages