feat: v3 - Add Twigfield integration for fields that render as object temp…
This PR is for Craft CMS v3
This PR adds integration with craft-twigfield to provide a Twig editor for fields in Craft CMS that are rendered as Twig object templates.
Description
Autocomplete is provided for:
- Twig syntax
- Twig filters, functions, and tags
- The Craft API, and any installed plugins
- Section layout shorthand syntax (e.g.:
{title}
It is provided in 3 places:
Editing Sections
In the Site Settings table field:
https://user-images.githubusercontent.com/7570798/195686357-db18d9ad-91f9-4931-b174-ea3457e65531.mov
Editing Entry Types
In the Title Format field:
https://user-images.githubusercontent.com/7570798/195686665-e59c54bc-56e4-4c28-aac8-c3d1b96c0db8.mov
Assets field settings
In the Default Upload Location, ** Asset Location**, & Allow Sub-folders fields:
https://user-images.githubusercontent.com/7570798/195688351-8141ad3b-7b4d-4a37-9d20-d48f4397e88d.mov
I realize that since this is in the CP, P&T may have stringent requirements about the look & feel. @engram-design for example pointed out that he didn't like the Twig logo in the field, for example.
I do think that there should be some kind of visual indicator baked into the field to let people know "hey, you can put any Twig here you want!". The current Craft CP is a little ambiguous in its description of these fields, leading some people to believe that only shorthand {title} type expressions are allowed.
My thought process was that I should use the actual Twig logo, even though I don't like how it looks. To me, it looks like creepy blades of grass, but it is their official logo. If I was listing Craft CMS on a web page, even if I didn't like the Craft CMS logo, probably I use should that rather than inventing my own logo.
However, the idea of a less obtrusive {{}} or {{ for a field indicator or such is something I'm perfectly open to. I just want it to look the same everywhere a Twigfield is used, so people know what to expect from that field. I think using just {} isn't really an indicator that it's Twig, and may confuse people into thinking it's only for the shorthand {title} syntax.
Also, things like the font size, field background, etc. are all customizable via Twigfield on a per-field basis, so wouldn't require any core changes to do them.