[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-25 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14710746#comment-14710746
 ] 

Dmitri Blinov commented on JEXL-177:


Oops, I didn't know it either, it must be something new from 3.0, thanks for 
the hint.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Assignee: Henri Biestro
Priority: Minor
 Fix For: 3.0


 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709220#comment-14709220
 ] 

Henri Biestro commented on JEXL-177:


Templates [...] are hell when it comes to conditional interpolation; do you 
have any blatant use case to illustrate ? Btw, thanks for your help.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709313#comment-14709313
 ] 

Dmitri Blinov commented on JEXL-177:


I see it as unified expressions are linear by their nature, suppose I want part 
of XML 

{code}
package${item}/package
{code}

to be shown if item contains value and not to be shown when it's empty. So I 
have to provide the following 

{code}
${not empty (item) ? package : }${item}${not empty (item) ? /package 
: }
{code}

Just imagine how things whould be complicated should we enhance it with some 
elseif/else logic...

So I think advanced templating by itself is a serious challenge, as an example, 
see how template engines like freemarker provide a directive to this

{code}
#if item != null
package${item}/package
/#if
{code}

but for me this JSP/JSTL style where structural programming is embedded in 
forms of directives or tags into templates is an opposite to what I'm inclining 
to in terms of overall efficiency and design.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709498#comment-14709498
 ] 

Henri Biestro commented on JEXL-177:


Documentation might be confusing and it may not fit your style but you could 
use something like:
{code}
$$ if (item != null) {
package${item}/package
$$ }
{code}
In templates (vs expressions), lines that begin with '$$' allow writing script 
fragments and you get access to the full syntax (var, functions, etc).
Other lines are interpolated.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709484#comment-14709484
 ] 

Adrian Crum commented on JEXL-177:
--

Actually, in Freemarker your expression would look like this:

{code}
package${item!}/package
{code}

http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_test


 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709031#comment-14709031
 ] 

Henri Biestro commented on JEXL-177:


Out of curiosity, this current enhancement request aside, if you are producing 
(lots of/mainly) text, why aren't you using Jxlt templates ?
Those are supposed to address the multiline + interpolation string use case.


 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709006#comment-14709006
 ] 

Dmitri Blinov commented on JEXL-177:


Oh, thanks a lot, I have completely overlooked the possibility to use Classes 
instead of Objects for functors, though as is comes out it was documented even 
in 2.0

{code}
funcs.put(fn177, fn177.class);
{code}

Nevertheless one problem keeps me unsatisfied, a *multiline* string literal, in 
the moment I'm using clumsy concatenations where string literals are intermixed 
with special *newline* variable, (which keeps string \r since we have none to 
insert it directly to literal), and the whole thing becomes a mess for 
relatively small XML fragment I'm trying to populate values with. It kind of 
works but in other languages like groovy, perl etc there is a notion of *String 
interpolation* syntax, and I believe its quite popular and in demand among 
users, so I thought if we have already had such a wonderful implementation of 
unified expressions it would be logical to have scripting and interpolation 
joined together in basic syntax.

Anyway, thanks for your effort.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-24 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14709123#comment-14709123
 ] 

Dmitri Blinov commented on JEXL-177:


I'm using both scripts and templates, and scripts are good at manipulating and 
preparing business data (fetching, filtering etc) and templates are good at 
representing them in string form but are a hell when it comes to conditional 
interpolation. 

At the moment I have both scripts and templates as independent parts of 
framework, they are called by framework in relay - scripts to provide nessesery 
data context and templates to finalyze the work, kind of MVC style, but in some 
non straight-forward cases there is a need to either use different templates in 
the end, or to develop complex logic where data and representation are 
interconnected, so that the only practical solution to this is to generate the 
result by manipulating its fragments, including some parts and ommiting others, 
directly in script where the data is being processed. 

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-23 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14708317#comment-14708317
 ] 

Henri Biestro commented on JEXL-177:


Yes, this is what I meant. A crude version could be:
{code}
public static class fn177 {
private final JexlContext context;
public fn177(JexlContext context) {
this.context = context;
}
public String print(String src) {
JxltEngine jxlt = (JxltEngine) context.get($jxlt);
if (jxlt != null) {
JxltEngine.Template template = jxlt.createTemplate(src);
if (template != null) {
StringWriter strw = new StringWriter();
template.evaluate(context, strw);
return strw.toString();
}
}
return ;
}

}

@Test
public void test177() throws Exception {
MapString, Object funcs = new HashMapString, Object();
funcs.put(fn177, fn177.class);
JexlEngine jexl = new JexlBuilder().namespaces(funcs).create();
JxltEngine jxlt = jexl.createJxltEngine();
MapContext context = new MapContext();
context.set($jxlt, jxlt);
String expr =  user = 'Dimitri'; fn177:print('Hello ${user}');
Object value = jexl.createScript(expr).execute(context);
Assert.assertEquals(expr, Hello Dimitri, value);
}
{code}

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-22 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14708051#comment-14708051
 ] 

Dmitri Blinov commented on JEXL-177:


You mean this can be achieved without syntax modification by means of adding 
functor that invokes template evaluation, or I missed some other way?

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-177) Unified expressions to be used in String literals in Jexl scripts

2015-08-21 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14706739#comment-14706739
 ] 

Henri Biestro commented on JEXL-177:


As a general rule, I'm very cautious about adding new constraints to the type 
system and even more so if it requires modifying the syntax.
Adding 'templates' to the general syntax raises a lot of warnings.
I'm pretty sure templates can be used - and their support implemented in 
vanilla JEXL - without the syntax modification.

 Unified expressions to be used in String literals in Jexl scripts
 -

 Key: JEXL-177
 URL: https://issues.apache.org/jira/browse/JEXL-177
 Project: Commons JEXL
  Issue Type: New Feature
Affects Versions: 3.0
Reporter: Dmitri Blinov
Priority: Minor

 Introduce new string literals to jexl script that allow unified expressions 
 to be used, string literals could use for example triple quoted (single or 
 double) syntax for delimiters, may include newlines and should not escape 
 single quotes
 {code}
 user = Bob; server = Test; s = Hello ${user}, welcome to ${server}; 
 return s;
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)