使用 haml 处理 xml-stylesheet :xmlns:blah 的正确方法是什么?
我正在尝试将博客与一些 xml 命名空间和 xml 样式表连接起来。
我目前这样做的丑陋方式看起来像这样:
!!! XML
= partial('xmlstyle')
%channel
......blah.....
= partial('xmlend')
_xmlend.xml.erb
_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">
看起来像:
</rss>
我现在应该坚持使用 erb 吗? haml 中必须有一种方法可以做到这一点,对吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Haml 没有 XML 样式表指令的语法,但您没有理由不能直接包含它们。至于
xmlns:blah
属性,您可以使用字符串作为属性名称,如下所示:您还可以通过
()
使用 HTML 样式属性: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:You could also use HTML-style attributes with
()
: