Question

Je suis en train de brancher un blog avec des espaces de noms XML et feuilles de style XML.

La façon laide que je fais cela ressemble actuellement comme ceci:

!!! XML
= partial('xmlstyle')
%channel
......blah.....
= partial('xmlend')

_xmlstyle.xml.erb ressemble à:

<?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 ressemble à:

</rss>

Devrais-je rester avec erb pour l'instant? Il doit y avoir une façon de le faire en droit haml?

Était-ce utile?

La solution

Haml ne pas la syntaxe des directives XML stylesheet, mais il n'y a aucune raison que vous ne pouvez pas les inclure directement. En ce qui concerne les attributs de xmlns:blah, vous pouvez utiliser des chaînes comme les noms d'attributs, comme suit:

<?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

Vous pouvez également utiliser des attributs HTML style avec ():

<?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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top