Multiline Filters
I assume there already is a related issue, but I wasn't able to find it if it exists.
Suggestion
Allow multiline filters in liquid blocks
{% liquid
# Showcase of multiline goodness
assign value = 'this-is-a-test'
| split : '-'
| uniq
| sort_natural
| join : ' '
%}
Reasoning
This would allow people to write cleaner, more structured
code that doesn't rely on the overuse of {% tag %} blocks
and would make writing 'pure code' a much easier task.
Extended
The same would be for parameters as well
{% liquid
render 'snippet'
, a : a
, b : b
%}
Agree, assign, render and echo should support multiline filters.
bump
Need multiline in general to fix the kludge of not being able to do filters, string expressions, or use capture or echo without having to prefix echo 'to ' echo 'every' echo 'single' echo 'line'
{% liquid # Current trudgery
capture no_line_breaks_either_watch_those_spaces_too
echo "to"
echo "every"
echo "single"
echo "line"
endcapture
echo no_line_breaks_either_watch_those_spaces_too
%}
Output: toeverysingleline
As single|double quote marks are not automatically inferred as echo'ing an expression.
And {% raw %} isn't useable inside {% liquid %} so that's not an escape hatch either
{% liquid # SYNTAX ERROR
capture echo
"to"
"every"
"single"
"line"
endcapture
%}
{% liquid # SYNTAX ERROR
capture echo
"to
every
single
line"
endcapture
%}
For example when creating preambles such as for html,json or graphql, or wrappers in html.
Currently it's either join all text to a single line or hop in and out of {% liquid %} tags, or type echo before everything.
@PaulNewton
I think your suggestions are a bit
of a different nature than mine.
I just want the existing syntax to
apply evenly , have it work the
same in liquid blocks that is.
You seem to propose completely new
concepts to the language , I would
recommend creating a dedicated issue.
Personally I think if the #1373 was
implemented , using multiple echos
wouldn't be that bad.
There is a possible low level overlap @PhoneDroid depending on how this or the other gets implemented in treating newlines and or quotes inside the {% liquid %} tag. Don't discount other feature discussions as a possible route to get the outcome, or near the outcome, being looked for.
{% liquid
assign value = 'this-is-a-test'
assign value = value | split : '-'
assign value = value | uniq
assign value = value | sort_natural
assign value = value | join : '
%}
is possibly equivalent to
assign value = 'this-is-a-test'
| split : '-'
| uniq
| sort_natural
| join : '
is possibly equivalent to
assign value = "'this-is-a-test'
| split : '-'
| uniq
| sort_natural
| join : ' "
# 🔍 notice the double-quote marks 👀
is possibly equivalent to
{%- liquid
capture media_id
echo "'FeaturedMedia-'
section.id
'-'
media.id"
endcapture
# interpolation without #{} or ${} literals syntax
-%}
is possibly equivalent to
{%- liquid
capture media_id
echo "FeaturedMedia-#{section.id}-#{media.id}"
endcapture
-%}
{{ media_id }}
Though probably more likely we'd end up with this
assign value = 'this-is-a-test'
| split : '-'
| uniq
| sort_natural
| join : '
endassign
echo 'FeaturedMedia-'
section.id
'-'
media.id
endecho
Sure those other proposals could - if available - be
used to write code to implement the same functionality
however I'm personally not interested to write code
utilizing that kind of syntax.