-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Bugfix: Fix indentation for chained method #88
base: master
Are you sure you want to change the base?
Conversation
Another couple of examples from the Craft CMS universe if this is useful. {% do seomatic.meta
.seoTitle("Page title")
.seoDescription("Page description")
.siteNamePosition("none")
.ogSiteNamePosition("none")
.ogType("website")
.ogTitle("Page title")
.ogDescription("Page description")
.ogImage("https://example.com/image.jpg")
.ogImageDescription("Image description")
.twitterCard("summary")
.twitterCreator("@exampleHandle")
.twitterTitle("Page title")
.twitterDescription("Page description")
.twitterImageDescription("Image description")
.twitterSiteNamePosition("none") %} Should probably be noted here that {% set posts = craft.entries
.section("news")
.orderBy("postDate DESC")
.limit(10)
.all() %} |
I'm surprised that people actually writing code like this. It defeat the purpose of templating engine. Putting business logic inside presentation layer is bad idea, IMO. Personal preference aside, this example is related to #91. If we print expression opening/closing in the same line, it won't be obvious where the start/end of expression since they're on different level of indentation. Current behaviour {{
var.method()
.otherMetod()
}} If bracket on same line {{ var.method()
.otherMetod() }} This output is not so "pretty" IMO. |
I think that's just the nature of having templating baked into a CMS and blurring the lines between presentation and logic. What do you think the best solution here is? could potentially force the closing to a new line? again not the most elegant solution. {% set posts = craft.entries
.section("news")
.orderBy("postDate DESC")
.limit(10)
.all()
%} FWIW the way that Twig tags can't be embedded within each other it's not quite like trying to find the subtle indentations of nested HTML tags for example. The closing tag is always going to be the next |
I don't know. It's been a while since I work on frontend code. It's hard to judge how it will look like from snippet.
Maybe you're right. |
b24006a
to
ac06385
Compare
This become more complicated than I originally thought. Input {{ craft.entries
.section("news")
.section("news")
.orderBy("postDate DESC")
.limit(10)
.all(a.b) }} Problem 1 {{
craft.entries.section('news').section('news').orderBy('postDate DESC')
.limit(10)
.all(a.b)
}} Problem 2 {{
craft
.entries
.section('news')
.section('news')
.orderBy('postDate DESC')
.limit(10)
.all(a
.b)
}}
{# this should fit in a single line #}
{{ craft.entries.all() }}
{# actual output #}
{{
craft
.entries
.all()
}} |
ac06385
to
6a1d8c0
Compare
6a1d8c0
to
e48f91d
Compare
Close GH-87
TODO
Add documentation about experimental featureDisable experimental feature by defaultInput
Expected Output
Current Implementation Output