jeudi 26 mars 2015

String with new lines stored in a meteor collection


I have some paragraphs entered by users stored in a string in a collection but the string has some rough formatting with new line characters. When I present that same paragraph later after accessing it from the collection, how do I have it retain that formatting? If I have the data object and I just do {{ data_paragraph }} it ignores the newlines and just spits out the string.


Is there a way to retain this formatting better when I reprint the data to the user?


Edit -


Here is some additional information :


The text paragraph I am trying to present formatted is just a textarea input through Autoforms. People might post a paragraph with \n characters but the whole string is getting stored in the collection.


Just as an example I pass the data in through Iron-Router :



SingleParagraphController = BaseController.extend({
template : 'singleParagraphPage',
waitOn : function() {
return Meteor.subscribe('singleParagram', this.params._id);
},
data: function() {
return Paragraphs.findOne({_id : this.params._id});
}
})


And then I want to be able to access the individual paragraph like :



<template name="singleParagraphPage">
<h2> {{ name }} </h2>
<p> {{ paragraph }} </p>
</template>


But it needs to have the same formatting with the new lines when they entered it initially into the text area. The new lines are stored in the string but when I just do it like above its just spits out the string and ignores it.





Aucun commentaire:

Enregistrer un commentaire