@zackad/prettier-plugin-twig 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zackad/prettier-plugin-twig",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Prettier Plugin for Twig",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,9 +49,16 @@ export const MacroParser = {
49
49
  let value;
50
50
  let node;
51
51
  if (tokens.nextIf(Types.STRING_START)) {
52
- value = tokens.expect(Types.STRING);
53
- tokens.expect(Types.STRING_END);
54
- node = createNode(StringLiteral, value, value.text);
52
+ if (tokens.test(Types.STRING_END)) {
53
+ // handle empty string as default value
54
+ value = tokens.expect(Types.STRING_END);
55
+ node = createNode(StringLiteral, value, "");
56
+ } else {
57
+ // handle non-empty string as default value
58
+ value = tokens.expect(Types.STRING);
59
+ tokens.expect(Types.STRING_END);
60
+ node = createNode(StringLiteral, value, value.text);
61
+ }
55
62
  }
56
63
  if (tokens.test(Types.NUMBER)) {
57
64
  value = tokens.expect(Types.NUMBER);
@@ -1,10 +1,11 @@
1
1
  import { STRING_NEEDS_QUOTES } from "../util/index.js";
2
2
 
3
- const p = (node, path, print) => {
3
+ const p = (node, path, print, options) => {
4
4
  node[STRING_NEEDS_QUOTES] = true;
5
5
  const printedName = path.call(print, "name");
6
6
  const printedValue = path.call(print, "value");
7
- return [printedName, " = ", printedValue];
7
+ const separator = options.twigFollowOfficialCodingStandards ? ": " : " = ";
8
+ return [printedName, separator, printedValue];
8
9
  };
9
10
 
10
11
  export { p as printNamedArgumentExpression };