xmlns:HAMLと何とかXML-スタイルシートを処理する適切な方法は何ですか?

StackOverflow https://stackoverflow.com/questions/1567614

  •  21-09-2019
  •  | 
  •  

質問

私はいくつかの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>

万一、私はちょうど今のERBにこだわりますか? 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