Forum Discussion
DonLarson
3 years agoQrew Elite
First, thank you. The concept of a "Quick Capture" is going to be helpful with many business cases.
Second, I am going to have to watch this several times and then come back to you with questions.
------------------------------
Don Larson
------------------------------
Second, I am going to have to watch this several times and then come back to you with questions.
------------------------------
Don Larson
------------------------------
PrashantMaheshw
3 years agoQrew Captain
Thank you Don, Mark and Forrest for kind encouragement. All future questions are appreciated. Mark do try running Quick Capture on a mobile page , it's a thing of beauty
Thank you @Doug Henning for detailed reply .Your reply and insights have made it worth to create and share.
I have one question . In my trial errors , I found if I only write {{x}} as in ("6": { "value": "{{loop.index}} {{x}}" } , output was always empty . I still don't understand why?
------------------------------
Prashant Maheshwari
------------------------------
Thank you @Doug Henning for detailed reply .Your reply and insights have made it worth to create and share.
I have one question . In my trial errors , I found if I only write {{x}} as in ("6": { "value": "{{loop.index}} {{x}}" } , output was always empty . I still don't understand why?
"6": { "value": "{{loop.index}} {{ x|trim }}" }
{% for x in plist if x|trim != '' -%}
Yes you are right , namespace was used specifically to have counter variable inside the loop for avoiding blank lines. I had no clue , there was a concept of conditional loop , this will help me tonnes of my other much longer jinja code !
{{ ',' if not loop.last }}
Again thank you for this much simpler code , I copy pasted {% if not loop.last %},{% endif %} from one of the pipeline sessions .
THANKS for the much simpler and easy to read code
------------------------------
Prashant Maheshwari
------------------------------
- DougHenning13 years agoCommunity ManagerHi @Prashant Maheshwari glad to help! I'm not sure why using
{{x}}
isn't working for you. That's standard Jinja, so maybe something else is causing the issue?
Do you do all your Jinja testing in Pipelines? I like to use an online Jinja parser like this one (https://j2live.ttl255.com) to test since it's quicker than running Pipelines after each change. Let's try it out and test the code!
1. Put the Jinja code in the Template box:
{%- set plist = a.quick_capture.split('\n') -%} { "to": "br8hpcpk7", "data": [ {%- for x in plist if x|trim != '' %} { "18": { "value": "{{a.related_director}}" }, "89": { "value": "{{a.id}}" }, "6": { "value": "{{loop.index}} {{ x|trim }}" } }{{ ',' if not loop.last }} {%- endfor %} ] }
2. Create a sample record structure in the Data input box. This simulates a Pipeline step A so data can be referenced as {{a.id}}:
{ "a": { "quick_capture": "testing\none\n\ntwo\nthree", "id": 12345, "related_director": "bob testing" } }
3. Click the [Render Template] button and you should get the results in Rendered Template box:
NOTE: The online parsers don't support all the filters that Pipelines provides (e.g. time) but can help with most Jinja.
Regarding {% if not loop.last %},{% endif %} vs {{ ',' if not loop.last }}, both are certainly acceptable. I tend to prefer the second for easy statements and the first for more involved if/then/else cases, but use whatever works best for you!
Hope that's helpful!
------------------------------
Doug Henning
------------------------------- PrashantMaheshw3 years agoQrew CaptainHI Doug,
Thanks for the site , I was indeed checking all permutations of code on pipeline page directly. This seems wicked fast .
I'm running into an error when I copy paste the code and data in rendered template output
Data error: expected '<document start>', but found '<scalar>' in "<unicode string>", line 7, column 2: } ^
------------------------------
Prashant Maheshwari
------------------------------- DougHenning13 years agoCommunity ManagerSorry about that, I don't know where that extra character came from. I just updated the post so you can recopy it without the error.
Once you get used to testing like this you'll really appreciate how fast it can be!
------------------------------
Doug Henning
------------------------------