Hey @jarednova. Just had a thought for a new feature that would help keep our twig templates well documented.
Just now I went through my twig templates and added a comment at the top of each one to describe what variables the template expects. This means my templates are now (hopefully) self-explanatory (in terms of the data being passed to it), so a front-end developer could take this and run with it, without having to know anything about the php.
Here's an example of what I mean - this comment appears at the top of my template:
{# expected variables:
my_first_variable: array of the form array[0][X] where X is 'start_date', 'end_date', 'title','subtitle'
my_second_variable: array of the form array[0][X] where X is 'title', 'start_date', 'end_date', 'url'
#}
This is a mild pain to do. I can imagine getting sloppy and not consistently doing this. Particularly when the 'api' changes.
It would be great if this comment could be automatically generated by Timber, so all I have to do is paste it into my twig template. Or maybe the Timber Debugger plugin could generate this? The output of the Debugger, is almost good enough to use as is, but its too verbose (because each value of the array gets output).
It sounds super lazy, but such a feature seems to be a good step towards encouraging well documented twig templates!
From @sleepyjackson:
Hey @jarednova. Just had a thought for a new feature that would help keep our twig templates well documented.
Just now I went through my twig templates and added a comment at the top of each one to describe what variables the template expects. This means my templates are now (hopefully) self-explanatory (in terms of the data being passed to it), so a front-end developer could take this and run with it, without having to know anything about the php.
Here's an example of what I mean - this comment appears at the top of my template:
This is a mild pain to do. I can imagine getting sloppy and not consistently doing this. Particularly when the 'api' changes.
It would be great if this comment could be automatically generated by Timber, so all I have to do is paste it into my twig template. Or maybe the Timber Debugger plugin could generate this? The output of the Debugger, is almost good enough to use as is, but its too verbose (because each value of the array gets output).
It sounds super lazy, but such a feature seems to be a good step towards encouraging well documented twig templates!