I am trying to write my first wordpress theme, and I am using haml
but I stumbled into a problem when I want to write statements such as the following, but in haml
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/reset.css" type="text/css">
I thought the haml
equivalent would simply use a :plain
tag for the php
but then I realised this would quickly turn very ugly, and it didn't much work.
So I am stuck with this:
%link{ :rel => "stylesheet", :href => "<?php bloginfo('stylesheet_directory'); ?>" }
Which, of course, is wrong.
I have had a look at phpHaml
and PhamlP
but I have no idea how to use them for my need of using a php
statement inside a :href
attribute in haml.
I am using CodeKit to recompile haml
into php
by simply changing the extension it compiles to from .html
to .php
and a lot of the documentation, to my understanding, requires I import their files in another .php
file to use their parsers.
Is there any way to achieve what I want to do?
Basically using php inline with haml, as easily as possible.
There is a way - the kind folks at WeLaika have created a plugin for wordpress called Wordless
It does exactly what you are asking (to use php inline with haml) as it is bundled with the phaml parser.
It requires a working ruby environment (using rvm) on your machine, and then you can write using ruby style "layouts and views" templates. It also allows for the use of SASS/SCSS in your stylesheets and Coffescript for your Javascript. But these are, of course, optional.
I also recommend using the two gems, Wordmove and Wordless_Gem
In Phamlp I use this:
%link(rel="stylesheet" href="#{ bloginfo('stylesheet_directory') }")