Jump to content

Why I love the Latte Template Engine


bernhard
 Share

Recommended Posts

I think you have to pass the variable to your included latte file:

{include '../blocks/' . $block->type . '.latte', block: $block}

 

  • Thanks 1
Link to comment
Share on other sites

10 hours ago, bernhard said:

It should work just like any other PW api... Does it render empty divs? Does it throw an exception?

I receive the markup but couldn't access any data somehow.

10 hours ago, bernhard said:

I'm never using {include ...}, I'm always using {$rockfrontend->render(...)}, but both should work.

Using $rockfrontend every time wouldn't save me that much time so I tried using it the .latte way.

10 hours ago, zoeck said:

I think you have to pass the variable to your included latte file

This did the trick. Thanks for this hint!

Link to comment
Share on other sites

On 7/19/2022 at 3:37 PM, bernhard said:
<ul>
  <li n:foreach="$page->parents()->add($page) as $item">
    <a href="{$item->url}" n:tag-if="$item->id != $page->id">
      {$item->title}
    </a>
  </li>
</ul>

If it's ok to dig up old threads....

@bernhard here, aren't you double encoding url, title? Assuming this is front end code, with `$pages->of(true)` and you have html entities text formatter in place on your title, url fields then a title with - say - an & would come out looking like &amp; as it would actually be &amp;amp;

 

Link to comment
Share on other sites

20 hours ago, artfulrobot said:

@bernhard here, aren't you double encoding url, title? Assuming this is front end code, with `$pages->of(true)` and you have html entities text formatter in place on your title, url fields then a title with - say - an & would come out looking like &amp; as it would actually be &amp;amp;

I think you are right for the ->title, but not for the ->url. The url is a property of the page object, not a regular field. So there is no textformatter applied and therefore it should just work like shown in the example. If you have a textformatter applied on the title field, then you'd need a |noescape filter in latte, yes.

 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@bernhard I absolutely love Rockfrontend and latte, it's so intuative!! The only issue I'm having is bracket pair colours in Visual Studio Code. Is there a way to get VSC to highlight the brackets and div pairs in a *.latte file? I'm sure there must be, I can't seem to find anything online. 

Link to comment
Share on other sites

Hey @Greg Lumley great to hear that, thx 🙂 

There is a latte extension for VSCode. It's not perfect, but it's ok:

1dEEuNK.png

Also there is no proper intellisense/code completion in latte files which is a pity, but I try to keep my latte files as clean as possible and put all the logic in the custom page class or in my Site.module.php so latte files are really just some simple markup and calling {$obj->method()} which is something that I can manage without typos most of the time 😄 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...