Jump to content

How do I comment out large chunks of JSON-T code in my template?

Recommended Posts

  • 2 weeks later...
  • Replies 8
  • Views 37.2k
  • Created
  • Last Reply

It looks like the Sqs JSONT parser does not support multi-line comments. According to the project page they are implemented in the Python version of the parser, I have no idea which version Sqs is using, but when tested, it only spits out an error.


{##BEGIN}multiline comment
{##END}

outputs:


<!-- SQUARESPACE_JSONT_ERROR
template: page default
(line/character offsets reference the template source code)
 1: SyntaxError EOF_IN_COMMENT at line 29 character 40: Reached EOF in the middle of a multi-line comment
-->

In theory you could just abuse the {.section} tag:


{.section multilineComment}
   <p>Assuming there's no variable named 'multilineComment',
   this bit of code should never be rendered.</p>
{.end}

Link to comment
  • 4 months later...

Turn on Word Wrap in your text editor and a single-line comment is as good as a multi-line comment. Like so:

{#Integer ege't urna. Praesent rhoncus, lorem nec facilisis ultrices, magna leo pellentesque neque, eu aliquam diam tellus aliquam pede. Vivamus gravida, risus in pellentesque ultricies, urna odio condimentum sem, ege't tempus augue felis non erat. Nam quis lorem semper pede accumsan vestibulum. Vivamus condimentum.}

If you really need a multi-line comment, you simply build your own out of multiple single-line comments, just like you would in an Apache configuration file:

{#Integer ege't urna. Praesent rhoncus, lorem nec facilisis ultrices,}
{#magna leo pellentesque neque, eu aliquam diam tellus aliquam}
{#pede. Vivamus gravida, risus in pellentesque ultricies, urna odio}
{#condimentum sem, ege't tempus augue felis non erat. Nam quis}
{#lorem semper pede accumsan vestibulum. Vivamus condimentum.}

Some text editors have commands that do this automatically for you.

Link to comment
  • 1 year later...
  • 10 months later...

Hi all.

This works for me:


{##
   <p>This code won't appear.</p>
   <p>Neither will this.</p>
   {website.id} <!--This won't show either.-->
   Nothing in here will render.
##}

EDIT: Squarespace has published the 'comment directive':


{# This is a single line comment}

{##BEGIN}
   This is a longer,
   mulitline comment
{##END}

But this also works for me, as does my initial example:


{##}
   This is a longer,
   mulitline comment
{##}

-Brandon


If this or any other answer helps you out, please give credit where credit is due and Accept and/or Up-Vote that answer. If it didn't help, feel free to inquire further or wait and see what others have to say. Code is provided without any warranty, expressed or implied.

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to comment
  • 2 years later...
  • 7 months later...
  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.