I'm trying to hook up a blog with some xml namespaces and xml stylesheets.
The ugly way that I'm doing this currently looks like so:
!!! XML
= partial('xmlstyle')
%channel
......blah.....
= partial('xmlend')
where
_xmlstyle.xml.erb looks like:
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
<?xml-stylesheet type="text/css" media="screen"
href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
_xmlend.xml.erb looks like:
</rss>
Should I just stick with erb for now? There has to be a way of doing this in haml right?
Haml doesn't have syntax for XML stylesheet directives, but there's no reason you can't include them directly. As for the xmlns:blah
attributes, you can either use strings as the attribute names, like so:
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
%rss{"xmlns:content" => "http://purl.org/rss/1.0/modules/content/",
"xmlns:wfw" => "http://wellformedweb.org/CommentAPI/",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:atom" => "http://www.w3.org/2005/Atom",
"xmlns:sy" => "http://purl.org/rss/1.0/modules/syndication/",
"xmlns:slash" => "http://purl.org/rss/1.0/modules/slash/",
"xmlns:feedburner" => "http://rssnamespace.org/feedburner/ext/1.0",
:version => "2.0"}
%channel
blah
You could also use HTML-style attributes with ()
:
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
%rss(xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"
version="2.0")
%channel
blah