How does handlebars(HBS) interact with the database ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

How does handlebars(HBS) interact with the database ?

Post by gautamz07 »

hey guys i just started using this blogging system called postleaf and it uses a templating language called handlebars http://handlebarsjs.com/ now i was wondering how handlebars really works , because on inpecting the code i found code like below:

Code: Select all

{{#each posts}}

    <div class="sample animated fadeIn">
        <div class="container">
            <div class="title animated fadeInUp">
                <a href="{{post_url}}">
                    <h1>{{title}}</h1>
                </a>
            </div>
            {{> sidebar}}
        </div>
    </div>

    <article class="excerpt animated fadeIn {{post_class}}">
        <div class="container">
            <p>{{excerpt words="100"}}&hellip;</p>
        </div>
    </article>

{{/each}}
Now the first piece of code:

Code: Select all

{{#each posts}}
I.E. the each function is something that would be done in PHP i believe , Now a while back i used twig .

I believe that HBS(handlebars) is javascript and twing on the other hand is a PHP Engine . How do these two compare.

Also how exactly does HBS interact with the database condidering that it is JS ??? thats one of my big questions .
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How does handlebars(HBS) interact with the database ?

Post by requinix »

gautamz07 wrote:Now the first piece of code:

Code: Select all

{{#each posts}}
I.E. the each function is something that would be done in PHP i believe ,
...yes. Rather than a loop in PHP that outputs multiple copies of some HTML markup, the loop happens in Javascript.
gautamz07 wrote:Now a while back i used twig .

I believe that HBS(handlebars) is javascript and twing on the other hand is a PHP Engine . How do these two compare.
One is Javascript templating and the other is PHP templating. Exactly like you said.
gautamz07 wrote:Also how exactly does HBS interact with the database condidering that it is JS ??? thats one of my big questions .
It does not. Your PHP has to do that.
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: How does handlebars(HBS) interact with the database ?

Post by gautamz07 »

Thanks requinix :D
Post Reply