[ 
https://issues.apache.org/jira/browse/NIFI-9561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17472694#comment-17472694
 ] 

Cemre Mengu commented on NIFI-9561:
-----------------------------------

Yes, actually that works :) That was a good practice anyway, thank you !

> 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, 
> image-2022-01-11-13-56-36-444.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.
> The processor config looks like this where node_ip, port etc. are attributes 
> of the incoming flowfile which will be applied to template and result will be 
> written to flowfile content
> !image-2022-01-11-13-56-36-444.png!



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

Reply via email to