我试图勾了一些XML命名空间和XML样式表一个博客。

这是我这样做的丑陋的方式目前看起来像这样:

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

,其中

_xmlstyle.xml.erb如下:

<?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如下:

</rss>

我是不是应该与雇员再培训局坚持现在? 必须有在HAML权这样做的方式是什么?

有帮助吗?

解决方案

Haml的不具有XML样式表的指令语法,但没有理由你不能直接包含它们。至于xmlns:blah属性,既可以使用字符串作为属性名称,像这样:

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

您也可以使用HTML风格的属性:

<?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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top