forked from trivago/prettier-plugin-twig-melody
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f54587b
commit 6abe20d
Showing
9 changed files
with
116 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% cache globally | ||
using | ||
key | ||
craft.some.rather.long.property.chain.request.path | ||
for | ||
3 | ||
weeks | ||
%} | ||
{% for block in entry.myMatrixField %} | ||
<p> | ||
{{ block.text }} | ||
</p> | ||
{% endfor %} | ||
{% endcache %} | ||
|
||
{# prettier-ignore #} | ||
{% cache globally using key craft.some.rather.long.property.chain.request.path for 3 weeks %} | ||
{% for block in entry.myMatrixField %} | ||
<p>{{ block.text }}</p> | ||
{% endfor %} | ||
{% endcache %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% header 'Cache-Control: max-age=' ~ (expiry.timestamp - now.timestamp) %} | ||
|
||
{# prettier-ignore #} | ||
{% header "Cache-Control: max-age=" ~ (expiry.timestamp - now.timestamp) %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% includeCssFile '/assets/css/layouts/' ~ entry.layout ~ '.css' %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% nav entry in entries %} | ||
<li> | ||
<a href="{{ entry.url }}">{{ entry.title }}</a> | ||
{% ifchildren %} | ||
<ul> | ||
{% children %} | ||
</ul> | ||
{% endifchildren %} | ||
</li> | ||
{% endnav %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% paginate craft.entries.section('blog').limit(10) as pageInfo, pageEntries %} | ||
|
||
{% paginate craft.entries.section('blog').limit(10) | ||
as | ||
pageInfo, | ||
pageEntries, | ||
pageProperties | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% redirect 'pricing' 301 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% switch matrixBlock.type %} | ||
{% case 'text' %} | ||
{{ matrixBlock.textField|markdown }} | ||
{% case 'image' %} | ||
{{ matrixBlock.image[0].getImg() }} | ||
{% default %} | ||
<p> | ||
A font walks into a bar. | ||
</p> | ||
<p> | ||
The bartender says, “Hey, we don’t serve your type in here!” | ||
</p> | ||
{% endswitch %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,59 @@ | ||
run_spec(__dirname, ["twig"], { | ||
twigMultiTags: [ | ||
"nav,endnav", | ||
"switch,case,default,endswitch", | ||
"ifchildren,endifchildren", | ||
"cache,endcache" | ||
] | ||
import { run_spec } from "tests_config/run_spec"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
/** @type {import('tests_config/run_spec').PrettierOptions} */ | ||
const formatOptions = {}; | ||
|
||
describe("Failing", () => { | ||
it("handle cache tags", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "cache.twig", | ||
formatOptions: { | ||
twigMultiTags: ["cache,endcache"] | ||
} | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle header tags", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "header.twig" | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle include css file tag", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "includeCssFile.twig" | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle nav tag", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "nav.twig", | ||
formatOptions: { | ||
twigMultiTags: ["nav,endnav", "ifchildren, endifchildren"] | ||
} | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle paginate tag", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "paginate.twig" | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle redirect tag", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "redirect.twig" | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
it("handle switch tag", async () => { | ||
const { actual, snapshotFile } = await run_spec(import.meta.url, { | ||
source: "switch.twig", | ||
formatOptions: { | ||
twigMultiTags: ["switch,case,default,endswitch"] | ||
} | ||
}); | ||
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
}); |