-
Notifications
You must be signed in to change notification settings - Fork 22
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
AST Rewrite #49
AST Rewrite #49
Conversation
Input: <img class="{{ if eq $index 1 }}
row-span-1 {{ else }} row-span-2 {{ end }}"/> Output: <img class="{{ if eq $index 1 }}row-span-1{{ else }}row-span-2{{ end }}" /> Input: <img class="{{ if eq $index 1 }}very long if content{{ else }}very else content{{ end }}" /> Output: <img
class="{{ if eq $index 1 }}
very long if content
{{ else }}
very else content
{{ end }}"
/> |
It seems to have a tendency to add spaces to right before |
ID Collisions are fixed in @jasikpark can you please add an input / output example? |
3 Bugs 🐛 :using A different problem is that it removed whitespace marks from blocks: input
output
And puts comments all on one line. If there's a different way to do comments in go templates, feel free to tell me though. input:
output:
And leaves no space between "define" blocks. input: output: |
Hello, Niklas. In Sublime Text 4, build 4107
test-file.html: <head>
{{ if eq .Page.Section "card" }}
<meta name="robots" content="noindex" />
{{ else }}
<meta name="robots" content="max-image-preview:large" />
{{ end }}
</head> Complete test project: |
@jasikpark Thanks a lot for reporting this, I'll fix both after each other and create 2 new beta releases. |
Awesome! Thanks for getting this working - I might have to actually look through to see how some of this works since I’m struggling setting up https://netlifycms.org custom editor shortcodes for my hugo site 😅 it’s all regex, which isn’t quite as flexible as I think I need.
…On June 5, 2021 at 9:15:31 AM, Niklas ***@***.******@***.***)) wrote:
@jasikpark(https://github.com/jasikpark) Thanks a lot for reporting this, I'll fix both after each other and create 2 new beta resleases.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub(#49 (comment)), or unsubscribe(https://github.com/notifications/unsubscribe-auth/ACRCMJBDZKP3WND746GUNTTTRIWQHANCNFSM45NYR6XQ).
|
Did you see the third problem I had linked as files? Two define blocks have no newline between them, making it hard to see the break in scope. |
@jasikpark for the first two issues you can try out: If you check out |
Example: input <div>
<div>
{{ dict
"country" "Norway"
"population" "5 millions"
"language" "Norwegian"
"language_code" "nb"
"weather" "freezing cold"
"capitol" "Oslo"
"largest_city" "Oslo"
"currency" "Norwegian krone"
"dialing_code" "+47"
}}
</div>
</div> output <div>
<div>
{{ dict
"country" "Norway"
"population" "5 millions"
"language" "Norwegian"
"language_code" "nb"
"weather" "freezing cold"
"capitol" "Oslo"
"largest_city" "Oslo"
"currency" "Norwegian krone"
"dialing_code" "+47"
}}
</div>
</div> |
// .prettierrc
{
/**
* Enables & disables spacing between go statements.
* E.g. {{ statement }} vs {{statement}}.
* Default: true
*/
"goTemplateBracketSpacing": false
} input {{ test }} output {{test}} |
Thanks, @NiklasPor. However, I don't know what I am doing wrong in Sublime Text. I always get the same error:
I'm using: |
|
|
|
The formatter now uses an AST to parse & print the go template.
New features:
<span {{ printf my attribute whatever }}></span>
worknpm i prettier-plugin-go-template@0.0.11-beta.5
to try out this version.