DEV Community

Gerald Villacarlos
Gerald Villacarlos

Posted on

Things I learned this week - Week 46 (2022 ed.)

  1. Is there a Mustache / Handlebars way of looping through an object properties?

    So with

    var o = {
      bob : 'For sure'
      roger: 'Unknown',
      donkey: 'What an ass'
    }
    

    Can I then do something in the template engine that would be equivalent to

    for(var prop in o)
    {
        //
  2. Since 1.0.6, looping in two dimensional arrays using #each is broken #278

    I was using #each to browse an array of arrays (i.e. [[1, 2],[3,4]]).

    With this kind of template for example:

    <table>
    {{#each rows}}
    <tr>
      {{#each .}}<td>{{.}}</td>{{/each}}
    </tr>
    {{/each}}
    </table>
    Enter fullscreen mode Exit fullscreen mode

    Quite classical, and I find #each more explanatory than #. in this case, that's why I use it.

    It suddenly broke itself when updating today (from 1.0.5beta to 1.0.6).

    Sample code:

    var handlebars = require('handlebars')
    // Using each
    var each = handlebars.compile('{{#each arrays}} [ {{#each .}} ( {{.}} ) {{/each}} ] {{/each}}')
    // Using implicit loops
    var loop = handlebars.compile('{{#each arrays}} [ {{#.}} ( {{.}} ) {{/.}} ] {{/each}}')
    
    // In 1.0.5beta
    each({arrays:[[1, 2, 3], [4, 5, 6], [7, 8, 9]]}) === ' [  ( 1 )  ( 2 )  ( 3 )  ]  [  ( 4 )  ( 5 )  ( 6 )  ]  [  ( 7 )  ( 8 )  ( 9 )  ] '
    loop({arrays:[[1, 2, 3], [4, 5, 6], [7, 8, 9]]}) === ' [  ( 1 )  ( 2 )  ( 3 )  ]  [  ( 4 )  ( 5 )  ( 6 )  ]  [  ( 7 )  ( 8 )  ( 9 )  ] '
    
    // In 1.0.6
    each({arrays:[[1, 2, 3], [4, 5, 6], [7, 8, 9]]}) === ' [  ]  [  ]  [  ] ' // DAFUQ ??
    loop({arrays:[[1, 2, 3], [4, 5, 6], [7, 8, 9]]}) === ' [  ( 1 )  ( 2 )  ( 3 )  ]  [  ( 4 )  ( 5 )  ( 6 )  ]  [  ( 7 )  ( 8 )  ( 9 )  ] '
    Enter fullscreen mode Exit fullscreen mode

    No PR attached sorry, no time to dig in the code right now

  3. nodejs xlsx module leading 0

    I'm using npm i xlsx for reading xlsx file. so my questions here ... in my xlsx sheet i given Indian standard date (DD/MM/YYYY) like 24/09/2020 so it's giving same value... if I give 03/09/2020 it's giving number 43898 like this. set cellDates:true it's giving 2020-03-09T00:00:00.000Z so here date take

  4. xlsx.utils JavaScript and Node.js code examples | Tabnine

    var rng = xlsx.utils.decode_range(range);... var c = typeof cell === 'string' ? xlsx.utils.decode_cell(cell) : cell;... return xlsx.utils.encode_range(rng);

    favicon tabnine.com
  5. Vuex - State Management

Top comments (0)