Hi Daniel,

2017-01-07 17:19 GMT+01:00 Daniel Dekany <ddek...@freemail.hu>:

> Saturday, January 7, 2017, 2:38:16 PM, Christoph Rüger wrote:
>
> > regarding promoting freemarker:
> > We are already doing that  in our Cloud-Data-platform where you can
> > use freemarker to do almost anything to transform, map and manipulate
> data.
> > We use it for our own application too (all templates) but we also
> > have chosen Freemarker as the main internal scripting language for data
> transformation.
> >
> > Here is a small example which just concatenates two variables in
> > the column "newtitle". Check it out if you want. It goes in a
> > similar direction as  http://freemarker-online.kenshoo.com/
> >
> > That being said I think we are also happy to contribute interesting
> > usecases, examples and whatever which could be spread using
> > SocialMedia. We have lots of examples in our own documentation
> > (here)
>
> I would only answer to this as technical guy.
>
> Your use cases are interesting in that you want not-so-technical
> people to write templates.

Exactly. Our customers are usually Excel-savvy but no programmers.


> For example, apparently, you have hard time
> dealing with null-s in your application (lot of `exp!`-s everywhere),
> so you may want to chime in when the null/missing handling
> improvements in FM3 are discussed.
>
Yeah we just decided to put ! by default everywhere. In our uses cases in
99% this is ok, as it should just render an empty String when something is
null.


>
> BTW I see some examples like ${datecalc("HOUR", 1)!?datetime}. I guess
> you can't possibly get a null there. Even if you do, ?datetime will be
> unhappy with the '' it had to convert to date-time, unless you have a
> custom data-time format there.
>
Your are probably right. in this case the ! is not needed and we could
avoid it. Can't remember why we've put it... maybe just to make it look
consistent to our customers and to avoid questions ;)


>
> > (it"s german...just use google translator) where we show how to do
> > various stuff with Freemarker expressions. We have also written some
> > own functions (here) which could also be useful maybe as core
> > built-ins (see here)
>
> Some questions/notes...
>
> How does `escapeHTML(exp)` differ from `exp?html`?
>
our escapeHTML uses
https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)
under
the hood.

>
> What's the practical use of `unescapeHTML(exp)`?
>
the opposite of escapeHTML  using
https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html#unescapeHtml(java.lang.String)

I can't remember but I think we had a case where we needed exactly the
escaping of Apache StringUtils and maybe it was different than what
Freemarker does? not sure...

>
> Also note that there's the auto-escaping machinery (output formats,
> ?esc, etc.) nowadays. It tries to removing the responsibility of
> escaping from the template author (without using #escape, which itself
> can be forgotten, or had to be added with TemplateLoader hacks). You
> can have HTML fragments in the data-model that are automatically *not*
> escaped, and everything else is automatically escaped. But even if
> your data-model can't be made that smart (i.e. HTML is also Space), at
> least you escape be default (and the you can do exp?noEsc to prevent
> it), which is safer than the opposite.
>
Yes, we want to try that out too, but many of our custom functions were
created a long time ago. We currently have a strong focus on ecommerce and
onlinemarketing, so the use-cases which drove those functions where coming
from such projects.



>
> As of `now()`, we have `.now`, though that returns a java.util.Date
> instead of a long. So the equivalent is `.now?long`, which is somewhat
> ugly. Note sure why and how often do you need the numerical version
> though.
>
We provide both to the users in some kind of context-menu. Maybe at the
time we wanted something as short but with the numerical version.


> > Just let me know if this is interesting, so we can think about
> > concrete stuff we could contribute where it fits.
>
> Calendar arithmetic is something users often request (i.e., adding a
> day, truncating the date down to the beginning of the month/day/hour
> and such). Anyway, if you have some concrete recommendation for
> built-ins, tell us.
>
Yes calendar arithmetic is a big one. we already have a dateCalc() function
and first/lastDayOfMonth() (which we will probably make more generic into
something like firstDayOf("year",mydate) or so.
Customers need this often to create date-ranges e.g. to make API-calls to a
REST-API (e.g. "give me all orders from last month")


> I'm interested to hear what your major pain points with FM are. A
> single template engine can't be ideal for everyone, but I'm hoping to
> cover more kind of usages in FM 3. (Or even in FM2, though I think
> things will be worked out in FM 3 and then maybe ported back where
> possible and if we have the resources)


Pain points...hmm.. maybe I would rather call it wishes, as I am generally
very happy with it. We really like the flexibility as it allows us to do
almost everything we want and also extend it. We even use it to parse XML
and JSON. The TemplateMethodModels are great.

*my wishes would be (for the moment):*
- be able to create custom built-ins (like TemplateMethodModels but with
the ?mybuiltin syntax). This would allow us to build some custom functions
with the same syntax and it could be used like a fluent-interface
?funcA?funcB?funcC

- date-arithmetic (see above)

- it would be cool if *?number* would handle trailing/leading spaces
instead of throwing exception (maybe as a configurable option) e.g. *Can't
convert this string to number: "1 " *

- some magic to somehow being able to avoid ?number at all when you know,
that your strings are numbers. not sure how possible this is but the
use-case is the following: the data is usually coming from a CSV-file which
is parsed and the columns are available as freemarker variables (as
strings). It would be great if one could just do ${quantity * price}
instead of ${quantity?number * price?number} But of course, maybe we could
do that maybe also under the hood already when populating the
datamodel...just thinking...
as I said just an idea. It would maybe make some use-cases easier, but of
course you would need to be careful to not add too much magic too FM. I
also like it that freemarker is kinda strict, because it makes it easier to
spot errors. But in our world we are also exposing it to non-technical
endusers and there we need some compromises.
Just take it as ideas :)

If you want I can collect more stuff and ask our team to collect some of
their wishes.
Do we have a place to put stuff like this?

Christoph

>
> > I don't want this to be considered spam - so let me know what you
> > think... but of course it would be promotion for us too
> >
> > Christoph
> >
> >
> >
> >
> >
> > 2017-01-07 13:36 GMT+01:00 Daniel Dekany <ddek...@freemail.hu>:
> > Saturday, January 7, 2017, 9:37:36 AM, Denis Bredelet wrote:
> >
> >> Hi Daniel,
> >>
> >>>> That was also my impression on the OFBiz tweet, as a software
> >>>> developer. The last is important, that I'm looking at it as a
> >>>> developer. FreeMarker, unless OFBiz, is mostly only interesting for
> >>>> them I believe. It doesn't have an UI that a manager type could click
> >>>> around. It's not a complete end-user product, it's Java library used
> >>>> internally by other products.
> >>
> >> I am thinking of contributing a very simple UI for FreeMarker.
> >> Something able to read a single template and process it with a
> >> datamodel pulled from various sources (user interface window,
> properties file, XML file…)
> >>
> >> Would that be useful and help with advertising FreeMarker?
> >
> > I believe it's something that many users need, because it's not always
> > convenient to try things right in the real product that integrates
> > FreeMarker. Especially if you just want the wrap your head around
> > something you have just read in the Manual. So I was considering
> > creating a such GUI, only my priorities (core maintenance) didn't
> > allow that. And then suddenly come
> > http://freemarker-online.kenshoo.com/, so we do have something like
> > that, but it could be improved further, also perhaps an offline
> > version (like a SWT application or such) can be handy (if you want to
> > connect to a local DB, etc).
> >
> > These template evaluators are also useful to draw the user's attention
> > to best practices and features. Like if you go to
> > http://freemarker-online.kenshoo.com/, you will be aware of output
> > formats, a relatively novel but very useful feature.
> >
> >> I have some code to use as a starting point on my website:
> >> http://bredelet.com/Denis/FreeMarker%20first%20steps.html
> >
> > These are some getting started examples. What are your ideas about the
> > final product?
> >
> >> Maybe this could come as a separate JAR to avoid loading UI classes
> unnecessarily.
> >
> >> Cheers,
> >> — Denis.
> >
> > --
> > Thanks,
> >  Daniel Dekany
>
> --
> Thanks,
>  Daniel Dekany
>
>


-- 
Christoph Rüger, Geschäftsführer
Synesty <https://synesty.com/> - Automatisierung, Schnittstellen, Datenfeeds
Tel.: +49 3641/559649

Xing: https://www.xing.com/profile/Christoph_Rueger2
LinkedIn: http://www.linkedin.com/pub/christoph-rueger/a/685/198

-- 
Synesty GmbH
Moritz-von-Rohr-Str. 1a
07745 Jena
Tel.: +49 3641 559649
Fax.: +49 3641 5596499
Internet: http://synesty.com

Geschäftsführer: Christoph Rüger
Unternehmenssitz: Jena
Handelsregister B beim Amtsgericht: Jena
Handelsregister-Nummer: HRB 508766
Ust-IdNr.: DE287564982

Reply via email to