Custom PHP generators

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom PHP generators

Jordo Odroj
I cannot begin to tell you how important this is to me, and I am very much looking forward to seeing the same thing that was done for Javascript, done for PHP. 
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Templates and SPOD

Renaud Bardet-2
Hi List !
 
I need help with HTML Templates (I'm using haxe.Template, not motionTwin.templo.Template)
 
I have a little database for a game and I'm writting a backend html interface to manage it,
basically I just need to print some database content and provide forms to populate it,
 
so I pass SPOD objects to the template's context, that's soo easy !
 
but some of my SPOD objects contains relations, for instance :
 
class User {
public var id : Int ;
public var name : String ;
public var group(dynamic,dynamic) : Group ;
private var groupId : Int ;
static funciton RELATIONS() { return [ {prop : "group", key : "groupId", manager : Group.manager } ] ; }
}
 
class Group {
public var id : Int ;
public var name : String ;
}
 
I'd want to print my users name and their group by name I tried :
 
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
 
That doesn't work, I think because Template uses Reflect and then don't access the property by the getter.
 
Do you have any suggestion ? I want to keep it easy looking if possible.
 
Regards,
 
Renaud

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Lars Madson
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.

Laurent





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Nicolas Cannasse
In reply to this post by Renaud Bardet-2
Le 12/01/2011 16:35, Renaud Bardet a écrit :

> Hi List !
> I need help with HTML Templates (I'm using haxe.Template, not
> motionTwin.templo.Template)
> I have a little database for a game and I'm writting a backend html
> interface to manage it,
> basically I just need to print some database content and provide forms
> to populate it,
> so I pass SPOD objects to the template's context, that's soo easy !
> but some of my SPOD objects contains relations, for instance :
> class User {
> public var id : Int ;
> public var name : String ;
> public var group(dynamic,dynamic) : Group ;
> private var groupId : Int ;
> static funciton RELATIONS() { return [ {prop : "group", key : "groupId",
> manager : Group.manager } ] ; }
> }

Accessing a dynamic property is similar to calling the
get_group(),set_group(g) methods.

Nicolas


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Philipp Klose-2
In reply to this post by Lars Madson
Hi

On 12.01.2011 16:47, Laurent Kappler wrote:
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>
It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.
Yes. Try to to switch to templo. You have way more options and it is a lot faster.

Laurent
Philipp
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Renaud Bardet-2
Thanks,
 
Unfortunately I can't have neko for this server, so templo is out of consideration.
 
Justin Mills told me about HxTemplate, developped by Franco Ponticelli, didn't find any documentation or wiki, it seems powerfull, do you know about it ?

Sent: Wednesday, January 12, 2011 4:53 PM
Subject: Re: [haXe] Templates and SPOD

Hi

On 12.01.2011 16:47, Laurent Kappler wrote:
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>
It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.
Yes. Try to to switch to templo. You have way more options and it is a lot faster.

Laurent
Philipp


--
haXe - an open source web programming language
http://haxe.org
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: Templates and SPOD

Lee Sylvester

You can use Templo with the PHP target.

 

Lee

 

 

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Renaud Bardet
Sent: 12 January 2011 16:40
To: The haXe compiler list
Subject: Re: [haXe] Templates and SPOD

 

Thanks,

 

Unfortunately I can't have neko for this server, so templo is out of consideration.

 

Justin Mills told me about HxTemplate, developped by Franco Ponticelli, didn't find any documentation or wiki, it seems powerfull, do you know about it ?

 

Sent: Wednesday, January 12, 2011 4:53 PM

Subject: Re: [haXe] Templates and SPOD

 

Hi

On 12.01.2011 16:47, Laurent Kappler wrote:

Le 12/01/2011 16:35, Renaud Bardet a écrit :

<table>

::foreach users::

<tr><td>::name::</td><td>::group.name</td></tr>

::end::

</table>

this would work for templo

<table>

::foreach user users::

<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>

::end::

</table>

It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::


maybe you can do:

<table>

::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::

<tr><td>::user.name::</td><td>::group.name</td></tr>

::end::

</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.

Yes. Try to to switch to templo. You have way more options and it is a lot faster.


Laurent

Philipp


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Philipp Klose-2
In reply to this post by Renaud Bardet-2
Hi,

templo is also for php. If could not install the templo compiler temploc on your server you could precompile the templates on you development computer.

Philipp

On 12.01.2011 17:39, Renaud Bardet wrote:
Thanks,
 
Unfortunately I can't have neko for this server, so templo is out of consideration.
 
Justin Mills told me about HxTemplate, developped by Franco Ponticelli, didn't find any documentation or wiki, it seems powerfull, do you know about it ?

Sent: Wednesday, January 12, 2011 4:53 PM
Subject: Re: [haXe] Templates and SPOD

Hi

On 12.01.2011 16:47, Laurent Kappler wrote:
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>
It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.
Yes. Try to to switch to templo. You have way more options and it is a lot faster.

Laurent
Philipp


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

jlm@justinfront.net
In reply to this post by Renaud Bardet-2
I looked at Ufront on google code tonight briefly, but could not find the hxml files when browsing, Franco do you have a ufront example that uses hxtemplate, I presume you use them together?

Cheers

;j

On 12 Jan 2011, at 16:39, Renaud Bardet wrote:

Thanks,
 
Unfortunately I can't have neko for this server, so templo is out of consideration.
 
Justin Mills told me about HxTemplate, developped by Franco Ponticelli, didn't find any documentation or wiki, it seems powerfull, do you know about it ?

Sent: Wednesday, January 12, 2011 4:53 PM
Subject: Re: [haXe] Templates and SPOD

Hi

On 12.01.2011 16:47, Laurent Kappler wrote:
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>
It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.
Yes. Try to to switch to templo. You have way more options and it is a lot faster.

Laurent
Philipp



--
haXe - an open source web programming language
http://haxe.org
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Custom PHP generators

Franco Ponticelli
In reply to this post by Jordo Odroj
Why do you feel that necessity? How the code should be generated in your opinion?
I personally don't see much interest in it but maybe I am overseeing something.

Franco

On Wed, Jan 12, 2011 at 12:20 PM, Jordo Odroj <[hidden email]> wrote:
I cannot begin to tell you how important this is to me, and I am very much looking forward to seeing the same thing that was done for Javascript, done for PHP. 
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Franco Ponticelli
In reply to this post by Renaud Bardet-2
HTemplate is not on haxe lib yet (we can plan a release if there is interest in it). You can find an introduction and usage example here: https://github.com/ciscoheat/htemplate/wiki
The library has been developed by Andreas Soderlund and me as a pair programming experience (a really good one).

Franco

On Wed, Jan 12, 2011 at 4:39 PM, Renaud Bardet <[hidden email]> wrote:
Thanks,
 
Unfortunately I can't have neko for this server, so templo is out of consideration.
 
Justin Mills told me about HxTemplate, developped by Franco Ponticelli, didn't find any documentation or wiki, it seems powerfull, do you know about it ?

Sent: Wednesday, January 12, 2011 4:53 PM
Subject: Re: [haXe] Templates and SPOD

Hi

On 12.01.2011 16:47, Laurent Kappler wrote:
Le 12/01/2011 16:35, Renaud Bardet a écrit :
<table>
::foreach users::
<tr><td>::name::</td><td>::group.name</td></tr>
::end::
</table>
this would work for templo
<table>
::foreach user users::
<tr><td>::user.name::</td><td>::user.getGroup().name</td></tr>
::end::
</table>
It think getter and setter are defined "get_x" and "set_x", therefore it should be:
::user.get_group().name::

maybe you can do:
<table>
::foreach user users::
::set group = user.group:: //or ::set group = user.getGroup()::
<tr><td>::user.name::</td><td>::group.name</td></tr>
::end::
</table>

but if I remember right you can't call an object method from the template object....I'm not sure.
So you would have to call user.group before executing the template and put it in your context: context.user = user; context.group = user.group;
I think you'd better swap to templo, simply much powerfull.
Yes. Try to to switch to templo. You have way more options and it is a lot faster.

Laurent
Philipp


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Franco Ponticelli
In reply to this post by jlm@justinfront.net
On Wed, Jan 12, 2011 at 11:41 PM, [hidden email] <[hidden email]> wrote:
I looked at Ufront on google code tonight briefly, but could not find the hxml files when browsing, Franco do you have a ufront example that uses hxtemplate, I presume you use them together?

Ufront uses htemplate as its default template engine (the project must be compiled with -D htemplate for the engine to be included). I have no samples so far because I want to bring in more things and try it on more projects before a beta release. Andreas too is contributing really interesting stuff. If you want to try ufront and you get stuck just let me know and I'll try to help.

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Templates and SPOD

Renaud Bardet-2
Thanks Franco, I'll look at it and let you know if it feels interesting or if any trouble.

Sent: Thursday, January 13, 2011 4:51 PM
Subject: Re: [haXe] Templates and SPOD

On Wed, Jan 12, 2011 at 11:41 PM, [hidden email] <[hidden email]> wrote:
I looked at Ufront on google code tonight briefly, but could not find the hxml files when browsing, Franco do you have a ufront example that uses hxtemplate, I presume you use them together?

Ufront uses htemplate as its default template engine (the project must be compiled with -D htemplate for the engine to be included). I have no samples so far because I want to bring in more things and try it on more projects before a beta release. Andreas too is contributing really interesting stuff. If you want to try ufront and you get stuck just let me know and I'll try to help.

Franco


--
haXe - an open source web programming language
http://haxe.org
--
haXe - an open source web programming language
http://haxe.org