Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9315795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:27:15+00:00 2026-06-19T02:27:15+00:00

I try to extract text between paragraph tag in a Jade view but it

  • 0

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:

<
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:27:16+00:00Added an answer on June 19, 2026 at 2:27 am

    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, context should be a parameter you pass to jade view, by res.render('view', {context : "My content."}) or res.locals

    so you can deal with your #{context} in Jade view

    if you want to declare variable context in Jade view

    it should be like

    -var context= "My content."

    p #{content}


    reply to jsdom code

    in your code

    posts[i] is undefined.

    I suppose u want to iterate posts, so you should use a iterator here

    you can use async module here

    in this case, map is very suitable

    see here for document -> async map

    Creation.findAll({where: "state = 1",order: 'id DESC', limit: 2}).success(function(creations) {
        Post.findAll({where: "state = 1",order: 'id DESC', limit: 2}).success(function(posts){
    
    async.map(posts, function(postEntity, callback){
    jsdom.env(
                postEntity.content,
                ["http://code.jquery.com/jquery.js"],
                function(errors, window) {
                    //deal with errors
                    if(errors) return callback(errors);
    
                    postEntity.content = window.$("p").text();
                    callback(null, postEntity);
                }
            );
    }, function(err, transformedPosts){
        if(err) return callback(err);
        res.render('index', {
            creations: creations,
            posts: transformedPosts,
            title: "Anthony Cluse | Portfolio"
        });
    });
    
        
    });
    });
    

    FYI, you should use control flow library to manage your callback code

    otherwise, it would be really hard to maintain

    I recommend async

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to extract text between parapgraph tag using RegExp in javascript. But it
I've made this to try to extract text. <script type = text/javascript> function extractText(node){
When I try to extract text from my PDF files, it seems to insert
I'm using ABCpdf to extract the text content of some PDF files, in particular
I use iText 5.3.3 I try to extract text from pdf file. I use
I try to display an HTML text with its styles, but the text is
I'm using BeautifulSoup to extract some text from an HTML but I just can't
I try to extract the media description of a SDP package. I have a
I am trying to parse html using BeautifulSoup to try and extract the webpage
I try to download a zip file to android and then extract the zip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.