Latte\Compiler: Tag <link> and </link>

5 years ago

Xethilos
Member | 19
+
0
-

I found interesting bug with tag link.

Error Message (Shorter): exception ‘Latte\CompileException’ with message 'Unexpected </link>, expecting </item>

Full code:

Not working

<rss version="2.0">
<channel>
    <title>{$website['name']}</title>
    <link>{$baseUri}</link>
    <description>{$website['description']}</description>
    <item n:foreach="$news as $row">
        <title>{$row->news_subject}</title>
        <link>{link //:Front:News:read $row->news_category_name, $row->news_id, $row->news_subject}</link>
        <description>{if $row->news_desc}{$row->news_desc}{if $row->news_desc|length === 255}...{/if}{else}{$row->news_content|striptags|entity_de|truncate:255}{/if}</description>
    </item>
</channel>
</rss>

Not working

<rss version="2.0">
<channel>
    <title>{$website['name']}</title>
    <link>{$baseUri}</link>
    <description>{$website['description']}</description>
    <item n:foreach="$news as $row">
        <title>{$row->news_subject}</title>
        <link></link>
        <description>{if $row->news_desc}{$row->news_desc}{if $row->news_desc|length === 255}...{/if}{else}{$row->news_content|striptags|entity_de|truncate:255}{/if}</description>
    </item>
</channel>
</rss>

Work without tag link

<rss version="2.0">
<channel>
    <title>{$website['name']}</title>
    <link>{$baseUri}</link>
    <description>{$website['description']}</description>
    <item n:foreach="$news as $row">
        <title>{$row->news_subject}</title>
        <description>{if $row->news_desc}{$row->news_desc}{if $row->news_desc|length === 255}...{/if}{else}{$row->news_content|striptags|entity_de|truncate:255}{/if}</description>
    </item>
</channel>
</rss>

5 years ago

David Grudl
Nette Core | 6850
+
+2
-

Place {contentType xml} on first line or use $latte->setContentType($latte::CONTENT_XML)

5 years ago

Xethilos
Member | 19
+
0
-

It works. I set content type only via presenter (httpResponse).