Skip to content

Commit

Permalink
[JSON] Apply refactored syntax to Go templates
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Dec 3, 2023
1 parent f8053b6 commit 451cd91
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ contexts:
3: source.js.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

script-json-content:
- meta_include_prototype: false
- match: '{{script_content_begin}}'
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1 # make sure to match only once
embed: scope:source.json.go-embedded-backtick-string
embed_scope: source.json.embedded.html
escape: '{{script_content_end}}'
escape_captures:
1: source.json.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: source.json.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

style-css-content:
- meta_include_prototype: false
- match: '{{style_content_begin}}'
Expand Down
15 changes: 15 additions & 0 deletions Go/HTML (Go).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ contexts:
3: source.js.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

script-json-content:
- meta_include_prototype: false
- match: '{{script_content_begin}}'
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1 # make sure to match only once
embed: scope:source.json.go
embed_scope: source.json.embedded.html
escape: '{{script_content_end}}'
escape_captures:
1: source.json.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: source.json.embedded.html
4: comment.block.html punctuation.definition.comment.end.html

style-css-content:
- meta_include_prototype: false
- match: '{{style_content_begin}}'
Expand Down
18 changes: 18 additions & 0 deletions Go/JSON (Go).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: JSON (Go)
scope: source.json.go
version: 2

extends: Packages/JSON/JSON.sublime-syntax

contexts:

prototype:
- meta_prepend: true
- include: scope:source.go#match-text-templates

string-prototype:
- meta_prepend: true
- include: scope:source.go#match-string-templates
22 changes: 22 additions & 0 deletions Go/tests/syntax_test_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@
| <- source.js.embedded.html meta.mapping.js punctuation.section.mapping.end.js
</script>

<script type="application/ld+json">
{
{{ key }}: {{.Site.Color}},
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.embedded.html
| ^^^^^^^^^ meta.mapping.json meta.interpolation.go
| ^^ meta.mapping.json - meta.interpolation
| ^^^^^^^^^^^^^^^ meta.mapping.value.json meta.interpolation.go
| ^ meta.mapping.json - meta.interpolation

"{{ key }}": "{{.Site.Color}}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.embedded.html
| ^ meta.mapping.key.json string.quoted.double.json punctuation.definition.string.begin.json
| ^^^^^^^^^ meta.mapping.key.json meta.interpolation.go - string
| ^ meta.mapping.key.json string.quoted.double.json punctuation.definition.string.end.json
| ^^ meta.mapping.json - meta.interpolation
| ^ meta.mapping.value.json meta.string.json string.quoted.double.json punctuation.definition.string.begin.json
| ^^^^^^^^^^^^^^^ meta.mapping.value.json meta.interpolation.go - string
| ^ meta.mapping.value.json meta.string.json string.quoted.double.json punctuation.definition.string.end.json
| ^ meta.mapping.json - meta.interpolation
}
</script>

<style>
.class {
color: {{ .Site.Color }};
Expand Down

0 comments on commit 451cd91

Please sign in to comment.