question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please remove defaultLayout

See original GitHub issue

Previously there were no defined defaultLayout and it was ok. But now we have: function ExpressHandlebars(config) { // Config properties with defaults. utils.assign(this, { handlebars : Handlebars, extname : '.handlebars', layoutsDir : undefined, // Default layouts directory is relative to express settings.view+layouts/ partialsDir : undefined, // Default partials directory is relative toexpress settings.view+partials/ defaultLayout : 'main', helpers : undefined, compilerOptions: undefined, }, config); That cause not natural behaviour in render view: `ExpressHandlebars.prototype.renderView = function (viewPath, options, callback) { … // Pluck-out ExpressHandlebars-specific options and Handlebars-specific // rendering options. options = { cache : options.cache, view : view, layout: ‘layout’ in options ? options.layout : this.defaultLayout,

    data    : options.data,
    helpers : helpers,
    partials: partials,
};

this.render(viewPath, context, options)
    .then(function (body) {
        **// Here I receive good hml template body, but while 
        // (layout: 'layout' in options ? options.layout : this.defaultLayout,)
       // and defaultLayout is always specified by default to 'main' then no way to return correct body 
       //and layoutPath pointing to main which is bad behaviour because we then need manually set 
       //defaultLayout: false ()
       
       // Register `hbs` as our view engine using its bound `engine()` function.
       //app.engine("hbs", hbs({
       //  defaultLayout: false,
       //  layoutsDir: "views/",
       //  extname: ".hbs"
       //}));
       //app.set("view engine", "hbs");**


        var layoutPath = this._resolveLayoutPath(options.layout);

        if (### layoutPath) {
            return this.render(
                layoutPath,
                utils.assign({}, context, {body: body}),
                utils.assign({}, options, {layout: undefined})
            );
        }

        **return body;**
    }.bind(this))
    .then(utils.passValue(callback))
    .catch(utils.passError(callback));

…`

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

5reactions
calebolincommented, May 21, 2019

couldn’t you just set defaultLayout: null?

Sure, but we still need this to be fixed since it’s a breaking change.

3reactions
JSteunoucommented, Jun 7, 2019

The defacto standard is semver in the JS / npm world that means

  • for the author: patch means hotfixes, minor means new features, major means all delayed features that causes breaking changes
  • for the consumer: use ^ (minor) or ~ (patch) prefix or none (freeze version) according to the level of trust you have to the library author and your own tests / CI.

Of course authoring libraries is tough so the duty is shared : we all need to be aware that mistake can be made and we need to test our upgrade. Even some big guys like the React team can had bugs in new release.

At our level we can alert the author and help him fix the bug either by PR, tests, feedbacks, … then wait 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

PLD Remove default layout - SAP Community
I can not remove a default layout for a specific customer Do you know how to do it?
Read more >
How to configure a StartupLayout that will remove all tiles from ...
Under Options, specify the path to the .xml file that contains the Start layout. For example, type \\ShareName\defaultlayout.xml. if we have ...
Read more >
How to change default layout in express using handlebars?
You can specify what layout you want to use as part of the render call. If you create a new layout called other.hbs...
Read more >
Delete default layout - Autodesk Community - AutoCAD
Is it possible that when you delete (all) the default layout that it uses a other default than AutoCAD does now. When deleting...
Read more >
How to remove compact layout from object?
You can delete the custom compact layout by using the delete button on the layout page. In your case, You have created a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found