Code Monkey home page Code Monkey logo

Comments (5)

ericf avatar ericf commented on July 29, 2024

I'm not sure what you mean, could you provide more info?

Express' res.render() method accepts a single view string name. What are you trying to accomplish, and would using partials work?

from express-handlebars.

owzzz avatar owzzz commented on July 29, 2024

In the docs you mention how you can select a layout. e.g "main" and then you use a {{{body}}} place holder to pull in a view. but what if in my main layout I wanted three columns and in each column a view place holder for each.

So I'd create three views in my layouts>views folder and then in my layout I'd add the place holders where I want those views to be rendered.

How would I go about doing this?

from express-handlebars.

ericf avatar ericf commented on July 29, 2024

You can use partials for this, and if you want to make this dynamic, check out issue #15 as it's related. Using the helpers I described in that issue you could do something like this:

layouts/main.handlebars:

...
<div class="sidebar-left">
    {{{block "sidebar-left"}}}
</div>
...

partials/settings-nav.handlebars:

<ul class="nav">
    <li><a href="/settings/email/">Change Email</a></li>
</ul>

settings.handlebars:

...
{{#contentFor "sidebar-left"}}
    {{> settings-nav}}
{{/contentFor}}
...

This way you can create arbitrary placeholders in your layout template, and fill in those placeholders inside your views—and do so by using partials.

from express-handlebars.

 avatar commented on July 29, 2024

Why do I need the settings.handlebars in this case?

Can I not have:

layouts/main.handlebars

<div class="wrapper">
    <section class="main-content">
        {{{block "main"}}}
    </section>
     <aside class="sidebar">
        {{{block "side"}}}
    </aside>
</div>

layouts/partials/main.handlebars

<h1> A Title </h1>
<p>Some Content Goes Here</p>

layouts/partials/side.handlebars

<nav>
    <ul>
        <li>A List item 1</li>
        <li>A List item 1</li>
        <li>A List item 1</li>
    </ul>
</nav>

from express-handlebars.

ericf avatar ericf commented on July 29, 2024

I don't remember what the action item is for this, so closing it…

from express-handlebars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.