Quick note on velocity comments.
1. They rock and I use them all the time!
2. You can't add the end comment "##" to macro calls or it will break things. #dotParse() etc.
3. You can't have your VTL file end with a comment "##" or it will break things. I.e. last line of vtl file is "#end##"
Also I agree with Will, when building a REST API it's best to do it either via an OSGI plugin or the new Velocity REST API feature. As a plugin builder I prefer the OSGI option, but if you aren't comfortable with that the new feature works as well.
Nathan I. Keiter | Lead Network Applications Programmer | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone:
717.337.6993
https://www.gettysburg.edu<
https://www.gettysburg.edu/>
________________________________
From:
dot...@googlegroups.com <
dot...@googlegroups.com> on behalf of Will Ezell <
wi...@dotcms.com>
Sent: Wednesday, May 12, 2021 12:23 PM
To:
dot...@googlegroups.com
Subject: Re: [dotcms] How to avoid newlines from VTL file output
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________
Two things -
First, I would strongly suggest that you try the Scripting API - it uses Velocity/VTLs and gives you the ability to script and just add things to the $dotJSON map and have it returned as "properly" formatted json, no matter what your velocity looks like. All you need to do is upload a get.vtl file under /application/apivtl/yourapi/get.vtl and then hit
https://yoursite.com/api/vtl/yourapi<
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fyoursite.com%2fapi%2fvtl%2fyourapi&c=E,1,0a4C5TDl8kzRYTSOsPF3lJMfvLcgYKX2q1bB9vae3aFWYJAydiHV9qach-kPlyASy31liQXawBk6cCzSypKPxJM3AE2auY07n4khD6Uu8DNQb_ybqpYRk6R0hw,,&typo=1>
You can learn more about it here:
https://dotcms.com/docs/latest/scripting-api<
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdotcms.com%2fdocs%2flatest%2fscripting-api&c=E,1,iOjPtCU93is3uotSOuJHvzbTE3kkPVSd-G--K3gsinKitxhxcihI_2qfDsJaXZ0aK812EJ6C86p9IBZODq2fQ70e8xxE_D5VOZ7JCy8Q&typo=1>
Second, if you end your line of Velocity with ## it should escape it and avoid adding new lines, e.g.
#set($content = $dotcontent.find("id")##
#set($test = "testing")##
On Wed, May 12, 2021 at 6:35 AM Visu <
k.vi...@gmail.com<mailto:
k.vi...@gmail.com>> wrote:
We have situation of more blank lines in the JSON output while generating a JSON out of multiple Lucene query content pulls via a dot file. Is there any solution available for this ?
--
http://dotcms.com<
https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,9CMkhHDn8VIraq5Deo31vT9OZtcPYQeVyjoyEbah6mBZScjZFuCzG1RjJvW5_BLxww8p-Pn80O0J2sya_crxKTPWN-jjeLwvLJ5EO3jQFYNuLq5yfF93yQ,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
dotcms+un...@googlegroups.com<mailto:
dotcms+un...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dotcms/4d1f071e-e54d-48e4-a244-1cad7f98bf03n%40googlegroups.com<
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f4d1f071e-e54d-48e4-a244-1cad7f98bf03n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,8VDn9aYmb90MDTM-k_VCnRMxCKpZSXDrTA2bEQW5kaq-NI9Bs0H5nxEmh-OlfrfCnw4TTAIXbp5s10FVko21LWWEbXj8y-W9Aasx_E4PE_G_oQo20Q,,&typo=1>.
--
[
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fdotcms.com%2fdA%2f99fe3769-d649%2f256w%2fdotcms.png&c=E,1,EQL03wnYo4dAdy7iVPz8Jz-ILmByj2y2IvEX6PHdr0PCJsHW0weGSqVQ0M3MdZTgcwX6RgZBT2kCvhNJAyTApzu7EuPan0A0ZTtdAxxh7g,,&typo=1]
wi...@dotcms.com<mailto:
wi...@dotcms.com> |
dotcms.com<
https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.dotcms.com%2f&c=E,1,JPU6JGBmJ4KybGdyCvN7xy_4i_xfr2641f3t0Dpi5Be-QzAhKk2RaXyeZtrB7GdHVmdXvTP9grwXkISoqItbC6dntGGKpw8cfJSSvuJOj1Weo7qfN2YfKSM5NpM,&typo=1>
[
https://origin.ih.constantcontact.com/fs172/1109987089110/img/11.png]<
https://twitter.com/dotcms> [
https://origin.ih.constantcontact.com/fs172/1109987089110/img/14.png] <
http://www.linkedin.com/company/dotcms> [
https://origin.ih.constantcontact.com/fs172/1109987089110/img/15.png] <
https://plus.google.com/+Dotcms> [
https://origin.ih.constantcontact.com/fs172/1109987089110/img/13.png] <
https://www.facebook.com/dotCMS>
--
http://dotcms.com<
https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,ECWJ4uNooB6nQXMLyPKdBzX0mGO-WN9oiYDULkChQqu3giM6JZQlxuAV2uGlYub27ss2w_eqvUcrKs0bF8CbFR-ArBXqAICzNW2Lm97dvW0PJfxr&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
dotcms+un...@googlegroups.com<mailto:
dotcms+un...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dotcms/CAPL0VyHLdGu0mB73JeLX8CJBJQrwuHFqd4GDuz85T8GFgCqhQw%40mail.gmail.com<
https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2fCAPL0VyHLdGu0mB73JeLX8CJBJQrwuHFqd4GDuz85T8GFgCqhQw%2540mail.gmail.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,X7VvnJskWRDbnsI1FZPFksyJ64yjrnNN_pvlYmXFr9CBT9Gpy5iDdVIsccEB8Jq0FsxpV12DHOfTs9fyeDmQpUGtkviaXtAXECyanTC8tI_5lSIDXg,,&typo=1>.