Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marked not converting line breaks to <p> tags or rendering HTML when fetched as collection in eco template #10

Open
tinacious opened this issue Nov 15, 2014 · 0 comments

Comments

@tinacious
Copy link

I am having issues with the Marked plugin not rendering line breaks as paragraph tags when content is fetched as a collection. I see the line breaks being added in Chrome dev tools.

I am also having issues with some HTML tags not being rendered, e.g. lists. Some tags (i.e. <i>) appear to render fine.

I've created a collection as so:

services: ->
  @getCollection('html').findAllLive(
      relativeOutDirPath: 'services'
      omitFromCollection: {$ne: true}
      [{weight:1}]
  )

In my Eco template, I am fetching the collection as so:

<% for service in @getCollection("services").findAll().toJSON(): %>

The following code will render some HTML (like <i> tags) but it will not convert \n to <p>:

<%- service.content %>

When it's rendered on its own page, it works perfectly. Am I creating the collection wrong or is this a bug?

I added some hacky JS for the meantime to fix the line breaks, and thankfully I don't need to use lists at this time, but it would be nice if the Marked plugin supported this out-of-the-box for fetching as collections as well.

For others who have the same problem, here's my quick fix for the paragraphs until the Marked plugin converts line breaks to paragraphs:

<p>
<% @serviceContent = service.content.replace(/\n/g, '</p><p>') %>
<%- @serviceContent %>
</p>

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant