sdepold / jquery-rss

An easy-to-use rss plugin for jquery with templating.
MIT License
454 stars 142 forks source link

layoutTemplate not working with <table> #118

Open mortenlein opened 7 years ago

mortenlein commented 7 years ago

Hi,

When I do a layoutTemplate: '<table>{entries}</table>' it never adds the start nor the end of the table tag, it only produces the tags within the entryTemplate.

I tried your examples in JSFiddle and I get the same results, so there is no interference from any other lib I am using in my project.

JSFIddle here; https://jsfiddle.net/AFHfn/2551/

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39242528-layouttemplate-not-working-with-table?utm_campaign=plugin&utm_content=tracker%2F310131&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F310131&utm_medium=issues&utm_source=github).
myrises commented 7 years ago

currently it is impossible, i think :( because jquery create a different objects structure from 'table' tag. compare its on browser console: $('<ul><entries></entries></ul>') and $('<table><entries></entries></table>') second object has two array members, moreover its .outerHTML not hold a <entries></entries>! its made as first member of array.

but you can make output rss entries in table by another way ;) add in your JSFiddle example next code - html:

<h2>Rss entries in table</h2>
<table id="rss2table"></table>

javascript:

$("#rss2table").rss("http://www.gosugamers.net/counterstrike/news/rss", {
    limit: 5,
    ssl: true,
    layoutTemplate: '{entries}',
    entryTemplate: '<tr><td><a href="{url}">{title}</a>{shortBodyPlain}[{author}@{date}]</td></tr>'
}).show();
mortenlein commented 7 years ago

I will try that, thanks for the reply

SimpleProgrammingAU commented 6 years ago

@myrises , It is interesting that you think tables are not possible for the time being (I have just tried, myself, with no success) but one of the examples in the readme goes like this:

$('#foo').rss(url, { layoutTemplate: "<table><tr><th>Title</th></tr>{entries}</table>", entryTemplate: "<tr><td>{title}</td></tr>" })

I now wonder if it should/did work, but does not anymore.