Discussion:
[FreeMarker-user] High performance with stateful TemplateDirectiveModel
Daniel Dekany
2014-12-15 15:46:05 UTC
Permalink
Yip, I know this problem, and I have just added a feature that targets
this and some more. Check out CachingUpperCaseDirective here:
https://github.com/freemarker/freemarker/blob/2.3-gae/src/test/java/freemarker/core/DirectiveCallPlaceTest.java

It will be a new feature in 2.3.22, which should be released in early
2015. So, for now you have to build it from the GitHub 2.3-gae branch
(it's important that it's the "gae" one), and please do so if you can,
and try to use it, and break it. I'm open for new suggestions of
course, until it's released.

(I would say that the 2.3-gae head is pretty safe to use in
production, in case waiting for the be release is a problem. The new
API-s and features can change a bit though.)
Hello all,
I'd thinking about how I could attain template "compile time generation"
optimizations the best way. Or maybe I'm just on the wrong track. Any
comments would be helpful.
I'm using Freemarker as html template engine. In that html I have
sometimes a few <script>-tags containing javascript. The javascript
could be optimized with one of numerous available optimization and
minification tools available. I was thinking about doing a
TemplateDirectiveModel that on the first run optimizes that code and any
calls thereafter only returns the optimized part. Is this a good way to
attain my goal (doing early, close to only once, expensive template
translation). Of course the code within has to be written so it doesn't
depend on anything that makes the code dynamic on each rendering.
As I said, any feedback on my thoughts would be greatly appreciated!
Have a great day!
//Jerker
--
Thanks,
Daniel Dekany
Jerker Klang
2014-12-16 03:04:22 UTC
Permalink
Hi Daniel!

Interesting and useful. I'll check it out as soon as I get some time for
it.

I'm not sure I can use the isNestedOutputCachable() feature since some
of the content that I want to cache may contain things that are using
dynamic expressions (like including a constant that is environment
specific).

Still the whole new feature is interesting.

Thanks!

//Jerker
Post by Daniel Dekany
Yip, I know this problem, and I have just added a feature that targets
https://github.com/freemarker/freemarker/blob/2.3-gae/src/test/java/freemarker/core/DirectiveCallPlaceTest.java
It will be a new feature in 2.3.22, which should be released in early
2015. So, for now you have to build it from the GitHub 2.3-gae branch
(it's important that it's the "gae" one), and please do so if you can,
and try to use it, and break it. I'm open for new suggestions of
course, until it's released.
(I would say that the 2.3-gae head is pretty safe to use in
production, in case waiting for the be release is a problem. The new
API-s and features can change a bit though.)
Hello all,
I'd thinking about how I could attain template "compile time generation"
optimizations the best way. Or maybe I'm just on the wrong track. Any
comments would be helpful.
I'm using Freemarker as html template engine. In that html I have
sometimes a few <script>-tags containing javascript. The javascript
could be optimized with one of numerous available optimization and
minification tools available. I was thinking about doing a
TemplateDirectiveModel that on the first run optimizes that code and any
calls thereafter only returns the optimized part. Is this a good way to
attain my goal (doing early, close to only once, expensive template
translation). Of course the code within has to be written so it doesn't
depend on anything that makes the code dynamic on each rendering.
As I said, any feedback on my thoughts would be greatly appreciated!
Have a great day!
//Jerker
Daniel Dekany
2014-12-16 11:31:08 UTC
Permalink
Post by Jerker Klang
Hi Daniel!
Interesting and useful. I'll check it out as soon as I get some time for
it.
I'm not sure I can use the isNestedOutputCachable() feature since some
of the content that I want to cache may contain things that are using
dynamic expressions (like including a constant that is environment
specific).
For that to work well we would need parse-time resolved variables...
that we don't have (also could be added later, but it has some
preconditions, namely, namespace prefixes, that's not yet implemented,
and is far away).
Post by Jerker Klang
Still the whole new feature is interesting.
Thanks!
//Jerker
Post by Daniel Dekany
Yip, I know this problem, and I have just added a feature that targets
https://github.com/freemarker/freemarker/blob/2.3-gae/src/test/java/freemarker/core/DirectiveCallPlaceTest.java
It will be a new feature in 2.3.22, which should be released in early
2015. So, for now you have to build it from the GitHub 2.3-gae branch
(it's important that it's the "gae" one), and please do so if you can,
and try to use it, and break it. I'm open for new suggestions of
course, until it's released.
(I would say that the 2.3-gae head is pretty safe to use in
production, in case waiting for the be release is a problem. The new
API-s and features can change a bit though.)
Hello all,
I'd thinking about how I could attain template "compile time generation"
optimizations the best way. Or maybe I'm just on the wrong track. Any
comments would be helpful.
I'm using Freemarker as html template engine. In that html I have
sometimes a few <script>-tags containing javascript. The javascript
could be optimized with one of numerous available optimization and
minification tools available. I was thinking about doing a
TemplateDirectiveModel that on the first run optimizes that code and any
calls thereafter only returns the optimized part. Is this a good way to
attain my goal (doing early, close to only once, expensive template
translation). Of course the code within has to be written so it doesn't
depend on anything that makes the code dynamic on each rendering.
As I said, any feedback on my thoughts would be greatly appreciated!
Have a great day!
//Jerker
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Thanks,
Daniel Dekany
Loading...