Closed twbartel closed 4 years ago
One tiny syntax thing: The twigMultiTags
tag names could maybe be an array instead of comma separated list.
@sjelfull Totally agree. I wanted to make them an array. However, I did not find a way to get that through Prettier's validation of options. If you know how to do that, please tell me! :-)
EDIT: To elaborate a bit more, this is how the option is defined:
twigMultiTags: {
type: "path",
category: "Global",
array: true,
default: [{ value: [] }],
description: "Make custom Twig tags known to the parser."
}
I use type: "path"
because it's the only string type available. There is only a handful of types allowed, and "array" is not one of them. I can tell Prettier that twigMultiTags
should be an array by setting array: true
, but I have not found a way to tell Prettier that the passed value should be an array of an arrays.
ATTENTION: Before merging this, https://github.com/trivago/melody/pull/154/commits has to be merged and released.
This merge request makes use of a new capability in the Melody parser to handle non-standard/unknown Twig tags.
By default, all unknown Twig tags will be handled and printed in a best-effort fashion that should be appropriate for a lot of Twig tags.
Additionally, a new option
twigMultiTags
is introduced which can be used to tell the parser about tag names that belong together, likenav
andendnav
. Example inspired by Craft CMS:This will basically add indentation to everything between the first and the last tag. Tag names must be comma separated.