Hi List
I'm working on a tutorial for using UFront, SPOD Macros and Erazor to create Web-Apps. So far it's going quite well, hope to post it soon. One quick question / issue I'm having (I'll try to simplify the code): My model: Question.hx @:index(userID) Nice and simple here... In my controller: QuestionController.hx class QuestionController extends Controller Again, too easy :) In my view: questions/list.html <h1>Questions</h1> All working, awesome. Now, what I would really like to do, to make it super easy, is make the mapping from "var user;" to "@user" in the template work. Currently we get: @question.get_user() => model.User If I wanted to make @question.user return the same as @question.get_user(), would I have to look at SPOD Macros, at Erazor, or at my own code? If we can nail that it's just one extra nicety for developing database driven apps :) (p.s. Loving your work Franco and Nicolas and anyone else involved) Jason -- haXe - an open source web programming language http://haxe.org |
Le 11/10/2011 12:36, Jason O'Neil a écrit :
> Hi List > > I'm working on a tutorial for using UFront, SPOD Macros and Erazor to > create Web-Apps. So far it's going quite well, hope to post it soon. [...] > If I wanted to make @question.user return the same as > @question.get_user(), would I have to look at SPOD Macros, at Erazor, or > at my own code? This would be feasible by using future Reflect.getProperty instead of Reflect.field, but might slowdown all other fields accesses. One thing that we did in Templo is to make a convention : all fields accesses starting with un underscore such as ::question._user:: are automatically translated to ::question.get_user():: Best, Nicolas -- haXe - an open source web programming language http://haxe.org |
Hi Jason,
first of all I am really glad you are using ufront, I am really eager to see your tutorial. In the git version of erazor there is already support for getters; they must be enabled adding -D getter_support to your compilation command.
If you can check that it works for you I will be glad to make a new release on haxelib before your tutorial goes live. Franco
On Tue, Oct 11, 2011 at 12:11 PM, Nicolas Cannasse <[hidden email]> wrote: Le 11/10/2011 12:36, Jason O'Neil a écrit : -- haXe - an open source web programming language http://haxe.org |
Sweet thanks,
I'll look into it now. Thanks both for the quick replies :) On Tue, Oct 11, 2011 at 7:28 PM, Franco Ponticelli <[hidden email]> wrote: Hi Jason, -- haXe - an open source web programming language http://haxe.org |
In reply to this post by Franco Ponticelli
Le 11/10/2011 13:28, Franco Ponticelli a écrit :
> Hi Jason, > first of all I am really glad you are using ufront, I am really eager to > see your tutorial. > In the git version of erazor there is already support for getters; they > must be enabled adding -D getter_support to your compilation command. Any detail how does it work ? Best, Nicolas -- haXe - an open source web programming language http://haxe.org |
Hi Nicolas,
I gave a few explanations in this thread : http://haxe.1354130.n2.nabble.com/Haxe-JS-ignores-getters-setters-when-using-Reflect-setField-td6816036.html The original idea comes from you though :) http://lists.motion-twin.com/pipermail/haxe/2011-September/thread.html#48031 For the moment, only getters are completely implemented, but I'd like to add setters soon, as well as Dynamic<T> / resolve(). IMHO, it would make sense to move it to hscript, if you're interrested, if not the standard library. Cheers, Clément On Tue, Oct 11, 2011 at 1:41 PM, Nicolas Cannasse <[hidden email]> wrote: > Le 11/10/2011 13:28, Franco Ponticelli a écrit : >> >> Hi Jason, >> first of all I am really glad you are using ufront, I am really eager to >> see your tutorial. >> In the git version of erazor there is already support for getters; they >> must be enabled adding -D getter_support to your compilation command. > > Any detail how does it work ? > > Best, > Nicolas > > -- > haXe - an open source web programming language > http://haxe.org > -- haXe - an open source web programming language http://haxe.org |
In reply to this post by Franco Ponticelli
Hi Franco
I'm having trouble getting it to compile. I have placed the latest erazor (git) and also the latest hscript (svn) in my src directory, but it's giving me this error: src/erazor/hscript/ReflectMacro.hx:24: characters 39-57 : haxe.macro.#Context has no field currentPos To be honest I'm still a complete newbie with understanding macros so not sure if it's a problem there or not. I'm running haXe 2.09-r4016 if it makes any difference. Any ideas? Jason On Tue, Oct 11, 2011 at 7:28 PM, Franco Ponticelli <[hidden email]> wrote: Hi Jason, -- haXe - an open source web programming language http://haxe.org |
Hi Jason,
I committed a quick fix here: git://github.com/clemos/erazor.git Let me know if it works. Cheers, Clément On Tue, Oct 11, 2011 at 2:21 PM, Jason O'Neil <[hidden email]> wrote: > Hi Franco > > I'm having trouble getting it to compile. I have placed the latest erazor > (git) and also the latest hscript (svn) in my src directory, but it's giving > me this error: > > src/erazor/hscript/ReflectMacro.hx:24: characters 39-57 : > haxe.macro.#Context has no field currentPos > > To be honest I'm still a complete newbie with understanding macros so not > sure if it's a problem there or not. I'm running haXe 2.09-r4016 if it > makes any difference. > > Any ideas? > > Jason > > On Tue, Oct 11, 2011 at 7:28 PM, Franco Ponticelli > <[hidden email]> wrote: >> >> Hi Jason, >> first of all I am really glad you are using ufront, I am really eager to >> see your tutorial. >> In the git version of erazor there is already support for getters; they >> must be enabled adding -D getter_support to your compilation command. >> If you can check that it works for you I will be glad to make a new >> release on haxelib before your tutorial goes live. >> Franco >> >> On Tue, Oct 11, 2011 at 12:11 PM, Nicolas Cannasse >> <[hidden email]> wrote: >>> >>> Le 11/10/2011 12:36, Jason O'Neil a écrit : >>>> >>>> Hi List >>>> >>>> I'm working on a tutorial for using UFront, SPOD Macros and Erazor to >>>> create Web-Apps. So far it's going quite well, hope to post it soon. >>> >>> [...] >>>> >>>> If I wanted to make @question.user return the same as >>>> @question.get_user(), would I have to look at SPOD Macros, at Erazor, or >>>> at my own code? >>> >>> This would be feasible by using future Reflect.getProperty instead of >>> Reflect.field, but might slowdown all other fields accesses. >>> >>> One thing that we did in Templo is to make a convention : all fields >>> accesses starting with un underscore such as ::question._user:: are >>> automatically translated to ::question.get_user():: >>> >>> Best, >>> Nicolas >>> >>> -- >>> 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 > -- haXe - an open source web programming language http://haxe.org |
Hi Clément
That's compiling now, thanks :) Now to see if the changes are working... <h1>Questions</h1> Yep! That's fantastic! Thanks so much for your help / work :) It's a clever solution, I like it. Jason On Tue, Oct 11, 2011 at 8:40 PM, clemos <[hidden email]> wrote: Hi Jason, -- haXe - an open source web programming language http://haxe.org |
In reply to this post by Franco Ponticelli
Hi Franco
Let me know if you get a chance to update haxelib with Clément's changes. :) Jason On Tue, Oct 11, 2011 at 7:28 PM, Franco Ponticelli <[hidden email]> wrote: Hi Jason, -- haXe - an open source web programming language http://haxe.org |
In reply to this post by Jason O'Neil-2
Great :)
I've asked Franco to pull the fix. Cheers, Clément On Tue, Oct 11, 2011 at 2:49 PM, Jason O'Neil <[hidden email]> wrote: > Hi Clément > > That's compiling now, thanks :) Now to see if the changes are working... > >> <h1>Questions</h1> >> @for (question in questions) >> { >> <div class="question"> >> <h2>@question.title</h2> >> <h4 class="user">User: @question.user.username</h4> >> <h4 class="date">Date: @question.date</h4> >> <h4 class="date">Number of Answers: >> @question.numberOfAnswers()</h4> >> <p>@question.text</p> >> </div> >> } > > Yep! That's fantastic! > > Thanks so much for your help / work :) It's a clever solution, I like it. > > Jason > > On Tue, Oct 11, 2011 at 8:40 PM, clemos <[hidden email]> wrote: >> >> Hi Jason, >> >> I committed a quick fix here: >> git://github.com/clemos/erazor.git >> Let me know if it works. >> >> Cheers, >> Clément >> >> On Tue, Oct 11, 2011 at 2:21 PM, Jason O'Neil <[hidden email]> >> wrote: >> > Hi Franco >> > >> > I'm having trouble getting it to compile. I have placed the latest >> > erazor >> > (git) and also the latest hscript (svn) in my src directory, but it's >> > giving >> > me this error: >> > >> > src/erazor/hscript/ReflectMacro.hx:24: characters 39-57 : >> > haxe.macro.#Context has no field currentPos >> > >> > To be honest I'm still a complete newbie with understanding macros so >> > not >> > sure if it's a problem there or not. I'm running haXe 2.09-r4016 if it >> > makes any difference. >> > >> > Any ideas? >> > >> > Jason >> > >> > On Tue, Oct 11, 2011 at 7:28 PM, Franco Ponticelli >> > <[hidden email]> wrote: >> >> >> >> Hi Jason, >> >> first of all I am really glad you are using ufront, I am really eager >> >> to >> >> see your tutorial. >> >> In the git version of erazor there is already support for getters; they >> >> must be enabled adding -D getter_support to your compilation command. >> >> If you can check that it works for you I will be glad to make a new >> >> release on haxelib before your tutorial goes live. >> >> Franco >> >> >> >> On Tue, Oct 11, 2011 at 12:11 PM, Nicolas Cannasse >> >> <[hidden email]> wrote: >> >>> >> >>> Le 11/10/2011 12:36, Jason O'Neil a écrit : >> >>>> >> >>>> Hi List >> >>>> >> >>>> I'm working on a tutorial for using UFront, SPOD Macros and Erazor to >> >>>> create Web-Apps. So far it's going quite well, hope to post it soon. >> >>> >> >>> [...] >> >>>> >> >>>> If I wanted to make @question.user return the same as >> >>>> @question.get_user(), would I have to look at SPOD Macros, at Erazor, >> >>>> or >> >>>> at my own code? >> >>> >> >>> This would be feasible by using future Reflect.getProperty instead of >> >>> Reflect.field, but might slowdown all other fields accesses. >> >>> >> >>> One thing that we did in Templo is to make a convention : all fields >> >>> accesses starting with un underscore such as ::question._user:: are >> >>> automatically translated to ::question.get_user():: >> >>> >> >>> Best, >> >>> Nicolas >> >>> >> >>> -- >> >>> 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 >> > >> >> -- >> 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 |
@Clément, thank you
@Jasone, the lib has been published ;) Franco On Tue, Oct 11, 2011 at 1:55 PM, clemos <[hidden email]> wrote: Great :) -- haXe - an open source web programming language http://haxe.org |
Thanks :D ... Sent from my phone, so apologies for any typos... On Oct 11, 2011 10:16 PM, "Franco Ponticelli" <[hidden email]> wrote:
@Clément, thank you -- haXe - an open source web programming language http://haxe.org |
Start of parenthesis.
Not to break the awesomeness of the subject of this thread. Just wanted to point out for some people which don't know github that this is the kind of reactivity one could gain with a *github base community*, just by using better tools.. (not to mention the ease when performing each step..) End of parenthesis. Can't wait to see this tutorial :) Great idea! Stéphane |
hi Jason,
"
In my controller: QuestionController.hx class QuestionController extends Controller Again, too easy :) " hmmm, this is where i'm stumbling at the mo?!?! how do you hook the model to the controller? doesn't seem obvious and easy to me :) not the first time this list has made me feel stupid though...
On 11 October 2011 17:41, sledorze <[hidden email]> wrote: Start of parenthesis. -- haXe - an open source web programming language http://haxe.org |
ooops, model is a package there! sorry...
On 21 December 2011 17:44, tom rhodes <[hidden email]> wrote: hi Jason, -- haXe - an open source web programming language http://haxe.org |
In reply to this post by tom rhodes
Hi Tom, Sorry if I was a bit condescending, I was writing after I had already figured it out, and so I guess it seemed easy to me because I already understood it :) I know what you mean by the list being pretty advanced though, most topics I feel pretty out of my depth! Now about your question... "how do you hook the model to the controller?" Um, short answer - manually. There is no special tie between the UFront Controller and the Haxe SPOD Class - they are two independent tools, that operate on their own. For example, I have a UFront controller that doesn't touch a database, but uses flat files. I also have a local project that uses SPOD, but doesn't ever touch UFront - it accesses it directly from main(). So, if you want your controller to print a line of text, you use something like: public function list() If you wanted to read from a file here, or a database, you would have to include that in your logic. UFront does not do that for you automatically. If we included the database logic, it might look like:
Where UFront gets helpful is with the templating engine it uses (Erazor). This ties into haxe objects really naturally, and basically can take a haxe object and make it available to the template. Because SPOD provides you with database rows AS haxe objects, they can be inserted into the templating system almost seamlessly. public function list() I know I've really just elaborated on what I wrote before, but hopefully it makes sense. Essentially: UFront does not have any formal ties to SPOD. You don't hook the model into the controller, rather, in the controller, you can do whatever you want. And if you want to use SPOD to load some database data, you can, but you do it just like you would if you used SPOD anywhere else, there is no special connection. The bit at the end simple passes the resulting haxe objects (representing database rows) to the template. Jason
On Dec 22, 2011 12:47 AM, "tom rhodes" <[hidden email]> wrote:
hi Jason, -- haXe - an open source web programming language http://haxe.org |
Free forum by Nabble | Edit this page |