bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

Template extend node #1163

Closed vinikey closed 5 years ago

vinikey commented 5 years ago

Hello there!

(I think is more a question than an issue)

First of all, thank you for this excellent framework! This is my first project that I try to make with f3. Since now everything goes really good and really fast.

The last day I'm trying to extend the Template instance as I can see here. Using the code

\Template::instance()->extend('testTag',function($node){ return "<div>".$node[0]."</div>"; });

for the

<testTag>{{ @sometitle }}</testTag>

I found that the extend doesn't render the @sometitle and in the extend function the return is

<div>{{ @sometitle }}</div>

I tried to use the extend at beforeRoute and at afterRoute, always before the call of echo \Template::instance()->render('template.htm');

Can anyone help me with that?

Thank you for your time!

geniuswebtools commented 5 years ago

It's been asked not to open issues for questions. You can ask for help from these resources.

Technical support is available at the official discussion forum: https://groups.google.com/forum/#!forum/f3-framework. If you need live support, you can talk to the development team and other members of the F3 community via IRC. We're on the FreeNode #fatfree channel (chat.freenode.net). Visit http://webchat.freenode.net/ to join the conversation. You can also download the Firefox Chatzilla add-on or Pidgin if you don't have an IRC client so you can participate in the live chat.

vinikey commented 5 years ago

I'm terribly sorry for this and really thank you for the information!

ikkez commented 5 years ago

@vinikey you can try it with \Template::instance()->build($node). You can also visit our Slack channel for more help.

vinikey commented 5 years ago

Thank you @ikkez !

As @geniuswebtools suggests, I found at google groups the use of the Template build as you suggest!

I had to build both node[0] and any of the node['@attrib'] in order to work, cause build($node) returns call_user_func_array() expects parameter 1 to be a valid callback, no array or string given if I have both content and attributes at extended tag.

Thank you again for this magnificent framework!

ikkez commented 5 years ago

also note that $node[0] is just the first content part.. there could be cases where you also have $node[1] ... node[n], depending on the inner content of course. Check out my TagHandler for more advanced use-cases... samples included. happy coding ;)