[ 
https://issues.apache.org/jira/browse/NIFI-9561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Cemre Mengu updated NIFI-9561:
------------------------------
    Description: 
Recently, I was trying to to create json/xml payloads from attributes to be 
used as requests. In most of the cases I had a template request to be filled 
with attributes. However, the easies way I could find was to use ReplaceText 
multiple times for individual replacements and for a large payload I had a long 
line of ReplaceText processors (as shown)

!image-2022-01-11-13-50-47-295.png!

When there isnt a template for request this can be done sub-optimally (I think) 
with AttributesToJson or JoltTransform processors (as discussed here 
[https://stackoverflow.com/questions/50415016/nifi-atttributes-to-json-not-able-to-generate-the-required-json-from-an-attr])

I would like to propose a new processor called ApplyTemplate where the 
processor simply applies matching attributes to the provided template string. 
In terms of java this will be something like:

Handlebars handlebars = new Handlebars();

Template template = handlebars.compileInline("Hello {{{ {{{}this }}}{}}}!");

System.out.println(template.apply("Handlebars.java")

using [https://github.com/jknack/handlebars.java]

This processor will dramatically simplify most of the tasks and the 
implementation is very simple. If this is something you would consider adding 
to core, I am ready to provide and work on the PR.

  was:
Recently, I was trying to to create json/xml payloads from attributes to be 
used as requests. In most of the cases I had a template request to be filled 
with attributes. However, the easies way I could find was to use ReplaceText 
multiple times for individual replacements and for a large payload I had a long 
line of ReplaceText processors (as shown)

!image-2022-01-11-13-50-47-295.png!

When there isnt a template for request this can be done sub-optimally (I think) 
with AttributesToJson or JoltTransform processors (as discussed here 
[https://stackoverflow.com/questions/50415016/nifi-atttributes-to-json-not-able-to-generate-the-required-json-from-an-attr])

I would like to propose a new processor called ApplyTemplate where the 
processor simply applies matching attributes to the provided template string. 
In terms of java this will be something like:

Handlebars handlebars = new Handlebars(); 

Template template = handlebars.compileInline("Hello {{{}this{}}}!"); 

System.out.println(template.apply("Handlebars.java")

using [https://github.com/jknack/handlebars.java]

This processor will dramatically simplify most of the tasks and the 
implementation is very simple. If this is something you would consider adding 
to core, I am ready to provide and work on the PR.


> Apply (Handlebars) Template Processor
> -------------------------------------
>
>                 Key: NIFI-9561
>                 URL: https://issues.apache.org/jira/browse/NIFI-9561
>             Project: Apache NiFi
>          Issue Type: Wish
>            Reporter: Cemre Mengu
>            Priority: Minor
>         Attachments: image-2022-01-11-13-50-47-295.png
>
>
> Recently, I was trying to to create json/xml payloads from attributes to be 
> used as requests. In most of the cases I had a template request to be filled 
> with attributes. However, the easies way I could find was to use ReplaceText 
> multiple times for individual replacements and for a large payload I had a 
> long line of ReplaceText processors (as shown)
> !image-2022-01-11-13-50-47-295.png!
> When there isnt a template for request this can be done sub-optimally (I 
> think) with AttributesToJson or JoltTransform processors (as discussed here 
> [https://stackoverflow.com/questions/50415016/nifi-atttributes-to-json-not-able-to-generate-the-required-json-from-an-attr])
> I would like to propose a new processor called ApplyTemplate where the 
> processor simply applies matching attributes to the provided template string. 
> In terms of java this will be something like:
> Handlebars handlebars = new Handlebars();
> Template template = handlebars.compileInline("Hello {{{ {{{}this }}}{}}}!");
> System.out.println(template.apply("Handlebars.java")
> using [https://github.com/jknack/handlebars.java]
> This processor will dramatically simplify most of the tasks and the 
> implementation is very simple. If this is something you would consider adding 
> to core, I am ready to provide and work on the PR.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to