Domanda

Sto cercando di collegare un blog con alcuni spazi dei nomi xml xml e fogli di stile.

Il brutto modo in cui lo sto facendo attualmente appare in questo modo:

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

dove

_xmlstyle.xml.erb, assomiglia a questo:

<?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, assomiglia a questo:

</rss>

Devo solo bastone con erb per ora?Ci deve essere un modo per farlo in haml giusto?

È stato utile?

Soluzione

Haml non ha sintassi XML stylesheet direttive, ma non c'è motivo, non è possibile includere direttamente.Come per il xmlns:blah attributi, è possibile utilizzare stringhe come i nomi di attributo, in questo modo:

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

Si potrebbe anche usare HTML e attributi di stile con ():

<?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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top