--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.
Good question. Using the Java Mustache library – which is very high performance – the callable functions would actually have to be in Java I believe (or at least callable as closures _from_ Java) and I’m not entirely sure you could engineer a dynamic proxy to make buildURL() callable in the context of the FW/1 object…?
Might be worth a try tho’…
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
And the answer is: yes you can:
https://github.com/framework-one/fw1/blob/mustache/examples/mustache/Application.cfc#L20
https://github.com/framework-one/fw1/blob/mustache/examples/mustache/views/main/default.html#L8
And here’s the Java 8 Function interface implementation:
https://github.com/framework-one/fw1/blob/mustache/framework/BuildURL.cfc
(you’d need one of those for each function you wanted to be able to call – or it would need to be generic… and I think it can only take one argument: the text between the open/close function tags)
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
Updated so you can call either FW/1’s view() to pull in another Mustache template or use “partials” (includes) in Mustache itself:
https://github.com/framework-one/fw1/blob/mustache/examples/mustache/views/main/default.html#L9-L10
(note the difference in paths!)
The function proxy mechanism is now generic and can be extended to any (single argument) FW/1 function:
https://github.com/framework-one/fw1/blob/mustache/examples/mustache/Application.cfc#L20-L26
I stuck a “fw1_” prefix in there to avoid conflicts with data in rc.
> Although I appreciate this development, it just seems to me to complicate matters
Well, this has come from a number of places:
· FW/1 for Clojure uses Selmer for views which is based on Django templates, so it’s a widespread style of handling views;
· The possibility of “pluggable” alternative templating engines for Lucee (and for ColdFusion, to be honest) has cropped up in a number of forums, multiple times, with Mustache or Django-style templates as one of the possibilities;
· Carl (Von Stetten) spurred me to try this because he was asking about “how much logic belongs in a view” and he’s fairly new to MVC-structured applications;
· One of the big problems with CFML is that it allows arbitrary code in the views – indeed in “old-school” CFML apps, there were only views and they contained all the logic: a big ol’ pile of spaghetti! So we moved to more structured approaches (like Fusebox act / dsp file conventions, then full-blown MVC) but we still have the _temptation_ to put too much logic in views… “because we can”…
So the (potential) benefit here of using Mustache for views in a FW/1 app is that it actually _simplifies_ the views by restricting what logic you can put in them, and that in turn answers the (common) question about “how much logic” is too much in a view. In addition, I’d be inclined to bet money on a Mustache-driven FW/1 web site being _faster_ than a regular CFML view-based website (because that Mustache engine is highly tuned and is not “a full programming language”).
Of course, if you already have almost no logic in your CFML views, this is somewhat moot.
Still… think of this as a concept car at an auto show, giving a glimpse of what a future world _might_ look like!
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.
The thought experiment I did last year has now been merged to *develop* as a “standard” example. It has been tested on ACF 10, 11, 2016, Lucee 4.5, 5.x. I’m going to do a little clean up on it and provide a formal extension point for alternative rendering engines. And maybe document it 😊
Not having to support CF9 has made a lot of things easier…
Sent from Mail for Windows 10
If you’re using FW/1 4.1.0 or 4.2.0, this is built in and you can see an example of it here https://github.com/framework-one/fw1/tree/develop/examples/mustache
Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
make an Ajax request to the controller which returns the data as JSON
Not sure what Ajax and JSON have to do with rendering views using Mustache (in FW/1)?
But then I’m also not sure what Joe is really asking either – if the CMS is written with FW/1, it’s already using CFML as the templating engine for the views. The example integration shown in the 4.1.0 download just replaces the CFML views with Mustache views instead (using the Java library that implements Mustache). If that CMS isn’t written in FW/1 already, then this discussion is moot…
Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood