I try to extract text between paragraph tag in a Jade view but it doesn’t work.
My subject:
<p> My content. </p> <img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTJ9ylGJ4SDyl49VGh9Q9an2vruuMip-VIIEG38DgGM3GvxEi_H"> <p> Second sentence. </p>
Jade view:
- var content = post.content.slice('/<p>(.*?)<\/p>/g');
p #{content}
Result:
<
why do u need to extract text between paragraph tag on server side??
that will be something we do on client side js
in your case,
contextshould be a parameter you pass to jade view, byres.render('view', {context : "My content."})orres.localsso you can deal with your
#{context}in Jade viewif you want to declare variable
contextin Jade viewit should be like
reply to
jsdomcodein your code
posts[i]is undefined.I suppose u want to iterate posts, so you should use a
iteratorhereyou can use
asyncmodule herein this case,
mapis very suitablesee here for document -> async map
FYI, you should use control flow library to manage your callback code
otherwise, it would be really hard to maintain
I recommend
async