Short way to include CSS and javascript tags with HAML

When including javascript or CSS in HAML you would normally have to do the following to include CSS:

%link{:type => "text/css", :rel => "stylesheet", :href => "/css/mycss.css"}

And for javascript:

%script{:type => "text/javascript", :src => "/js/myscript.js"}

I was wondering if HAML does not have a short way of including these tags (to get content from a source of course, not inline), that omits the need for the type and rel attributes, since these are invariable anyway.

Note that Ruby on Rails provides this feature via a function, but I'm not using rails.


You don't need the script's type attribute, and you can use the html syntax


you could always create a "helper" to generate it if you feel like it

Need Your Help

how to parse the file?

python python-3.x lxml lxml.html

the following code parses the string.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.