Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    István Lantos
    @DJviolin

    This really bugs me. In the past worked without problem that if I refreshed my handlebars template without server reload, the changed text appeared on my site. Something blocking this and it's not working. Someone can take a look?

    app.js

    /routes/contact.js

    /views/contact.hbs

    István Lantos
    @DJviolin
    SOLUTION: https://github.com/expressjs/express/issues/2960#issuecomment-203039852
    This is a normal behavior for the NODE_ENV=production environment variable. Few days ago I turned this on and I didn't realized it can cause this.
    Peeter Tomberg
    @peeter-tomberg
    Hello
    Is there a way to have "global" data in my helpers
    E.g. meta keywords / description
    Gurpreet SIngh
    @Gurpreet3131
    hi. is this group active nowadays?
    Ginger
    @gingerwilliams
    I guess not
    Ginger
    @gingerwilliams
    Is it possible to render a partial without rerendering the entire page? I’m using express-handlebars
    Carlos Hernandez V.
    @chernandezv_kai_twitter
    Hi
    someone here?
    Ambika Kumar
    @ambikarajbadal
    Hello
    Bhushan
    @anshbhushan
    Y
    franciscohanna92
    @FranciscoHanna
    Hi! Is the package being actively developed?
    Dan Malone
    @danmalone89
    Hey guys, I'm looking for some assistance with an issue I'm having while trying to pass an object from axios to router.get so I can render it on the view via handlebars. I don't think my issue is with axios directly, but maybe one of you can point me in the right direction
       router.post ('/search', function (req, res, next) {
          let body = req.body.value;
          axios //axios is working as desired
            .get ('search?value=' + body)
            .catch (function (error) {
              console.log (error);
            })
            .then (function (response) {
              let contacts = response.data.Contacts;
              console.log(contacts) // This returns the response object as desired
              renderResults (contacts);
            });
        });
    
        function renderResults (contacts) {
          router.get ('/', function (req, res, next) {
            console.log (contacts); // This does nothing
            res.render ('index', {contacts: contacts});
          });
        }
    Will Adams
    @bushblade

    @danmalone89 Why do you need your renderResults function at all surely

    router.post ('/search', function (req, res, next) {
          let body = req.body.value;
          axios //axios is working as desired
            .get ('search?value=' + body)
            .catch (function (error) {
              console.log (error);
            })
            .then (function (response) {
              let contacts = response.data.Contacts;
              console.log(contacts) // This returns the response object as desired
              res.render('index', {contacts: contacts});
            });
        });

    would work?

    Dan Malone
    @danmalone89
    @bushblade You know I tired that too and it didn't work, let me show you
    @bushblade This is my routes/index.js, I have a index.hbs that has {{contacts}} in it
    var express = require ('express');
    var router = express.Router ();
    var app = express ();
    var axios = require ('axios');
    app.use (express.urlencoded ({extended: false}));
    app.use (express.json ());
    axios.defaults.baseURL = process.env.URL;
    axios.defaults.headers.common['Authorization'] = process.env.AUTH;
    
    router.get ('/', (req, res, next) => {
      res.render ('');
    });
    
    router.post ('/', (req, res, next) => {
      let searchValue = req.body.value;
      axios
        .get ('/search?value=' + searchValue)
        .then ((response) => {
          let contacts = response.data.Contacts
          console.log(contacts) // displays the data correctly
          res.render('', contacts) // doesn't do anything :(
        })
        .catch ((error) => {
          console.log (error);
        })
    });
    
    module.exports = router;
    Will Adams
    @bushblade
    @danmalone89 What are you doing with the contacts in index.handlebars then?
    Dan Malone
    @danmalone89
    @bushblade
      <div class="modal fade modal-open" id="resultsModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="modalLabel">
                Select a Client
              </h5>
            </div>
            <div id="resultsModal" class="modal-body">
              <div id="contactTable" class="list-group-flush text-left text-light">
                {{contacts}}
              </div>
            </div>
            <div class="modal-footer">
              <button id="modalCancelBtn" type="button" class="btn btn-primary">Cancel</button>
            </div>
          </div>
        </div>
      </div>
    @bushblade If I could get something to actually render, I would then probably filter that data just to show the keys i need with
                {{#each listOfContacts}}
                <li>{{@index}}: {{this.FullName4}}</li>
                {{/each}}
    obviously using {{#each contacts}} instead, just had that snippet saved for future use
    Sedric Heidarizarei
    @saeedhei
    Hello, I am using Handlebars in an Express Node.js app. My layout.handlebars file includes a <head> section.
    How can I make the <head> section different for different pages because of SEO?
    // Init App
    var app = express();
    
    // View Engine
    app.set('views', path.join(__dirname, 'views'));
    app.engine('handlebars', exphbs({defaultLayout: 'layout'}));
    app.set('view engine', 'handlebars');
    😕 Dwi Purnomo
    @port8084_twitter

    helo, why my partials page could not be found? here is my express setting

    const app = express();
    app.set("views", "dist/views");
    
    const hbs = expHbs.create({
      defaultLayout: 'main',
      partialsDir: 'dist/views/partials',
    });
    
    app.engine("handlebars", hbs.engine);
    app.set("view engine", "handlebars");

    here is the partial calling

    <body>
      {{> page/navbar1}}

    here is the error message:

    Error: The partial page/navbar1 could not be found
        at Object.invokePartial (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:281:11)
        at Object.invokePartialWrapper [as invokePartial] (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
        at Object.eval [as main] (eval at createFunctionContext (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:28)
        at main (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
        at ret (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
        at ret (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
        at ExpressHandlebars._renderTemplate (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/express-handlebars/lib/express-handlebars.js:247:12)
        at ExpressHandlebars.<anonymous> (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/express-handlebars/lib/express-handlebars.js:173:21)
    Error: The partial page/navbar1 could not be found
        at Object.invokePartial (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:281:11)
        at Object.invokePartialWrapper [as invokePartial] (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
        at Object.eval [as main] (eval at createFunctionContext (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:28)
        at main (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
        at ret (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
        at ret (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
        at ExpressHandlebars._renderTemplate (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/express-handlebars/lib/express-handlebars.js:247:12)
    at ExpressHandlebars.<anonymous> (/home/dp/kerja/tutorial-typescript-express-sequelize/node_modules/express-handlebars/lib/express-handlebars.js:173:21)

    ```

    Ambika Kumar
    @ambikarajbadal

    After executing this code why I'm getting too much data through in output after sending only email data from postman

    console.log(req.check('email', 'Invalid email').isEmail().notEmpty())

    And below is output

    ambika@Developer:~/Desktop/nodejsrestapi$ nodemon
    [nodemon] 1.18.1
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching: *.*
    [nodemon] starting `node server.js`
    Server is listninig on port 8000
    ambika
    { [Function: middleware]
      equals: [Function],
      contains: [Function],
      matches: [Function],
      isEmail: [Function],
      isURL: [Function],
      isMACAddress: [Function],
      isIP: [Function],
      isIPRange: [Function],
      isFQDN: [Function],
      isBoolean: [Function],
      isAlpha: [Function],
      isAlphanumeric: [Function],
      isNumeric: [Function],
      isPort: [Function],
      isLowercase: [Function],
      isUppercase: [Function],
      isAscii: [Function],
      isFullWidth: [Function],
      isHalfWidth: [Function],
      isVariableWidth: [Function],
      isMultibyte: [Function],
      isSurrogatePair: [Function],
      isInt: [Function],
      isFloat: [Function],
      isDecimal: [Function],
      isHexadecimal: [Function],
      isDivisibleBy: [Function],
      isHexColor: [Function],
      isISRC: [Function],
      isMD5: [Function],
      isHash: [Function],
      isJSON: [Function],
      isEmpty: [Function],
      isLength: [Function],
      isByteLength: [Function],
      isUUID: [Function],
      isMongoId: [Function],
      isAfter: [Function],
      isBefore: [Function],
      isIn: [Function],
      isCreditCard: [Function],
      isISIN: [Function],
      isISBN: [Function],
      isISSN: [Function],
      isMobilePhone: [Function],
      isPostalCode: [Function],
      isPostalCodeLocales: [Function],
      isCurrency: [Function],
      isISO8601: [Function],
      isRFC3339: [Function],
      isISO31661Alpha2: [Function],
      isISO31661Alpha3: [Function],
      isBase64: [Function],
      isDataURI: [Function],
      isMimeType: [Function],
      isLatLong: [Function],
      isWhitelisted: [Function],
      toDate: [Function],
      toFloat: [Function],
      toInt: [Function],
      toBoolean: [Function],
      ltrim: [Function],
      rtrim: [Function],
      trim: [Function],
      escape: [Function],
      unescape: [Function],
      stripLow: [Function],
      whitelist: [Function],
      blacklist: [Function],
      normalizeEmail: [Function],
      toString: [Function],
      optional: [Function],
      custom: [Function],
      customSanitizer: [Function],
      exists: [Function],
      isArray: [Function],
      isString: [Function],
      withMessage: [Function],
      not: [Function],
      _context:
       { optional: [Getter],
         negateNext: false,
         message: 'Invalid email',
         fields: [ 'email' ],
         locations: [ 'params', 'query', 'body', 'headers', 'cookies' ],
         sanitizers: [],
         validators: [ [Object], [Object] ] },
      notEmpty: [Function],
      len: [Function] }
    I'm using express validator for that in nodejs.
    Joe Early
    @JoeEarly
    Hi all, why does this not work as I think it should:
    image.png
    I have a object that conains a value featured : true
    WHy does my if block not render using that?
    Joe Early
    @JoeEarly
    Anyone got a moment to help me with {{moment}} :)
    I have a date in my object and id like to work out the time from that date which will be in the past.
    4lbertoDelgado
    @4lbertoDelgado
    hi, i need to know what is the difference between hbs and express.handlebars. Please help
    Jennifer Eberlei
    @jennifer.eberlei_gitlab
    Hi there, this might seem off-topic but I am trying to create a handlebars helper (and I might be wrong here) but would someone bare with me and look at my code? I am having an issue returning a value from a promise and (since I am new to promises) I have no clue what I am doing (wrong).