Disclaimer to start with: This is an issue just to start a discussion to include a front-enders view on this.
Background:
If I'm correct, the {{PATHS}}
variable will be deprecated and (partly) replaced by the Asset() function.
This will cause
<img src="{{ paths.theme }}images/logo.png" alt="Client logo" />
To look like this:
<img src="{{ asset('images/logo_footer.png', 'theme') }}" alt="Client logo" />
Why?
There are a number of reasons why, as a frontender / templater think this is not desirable.
1. It obsures your templating code with magical backender bits.
The {{paths.theme}}
was used to shorten the longer absolute path, and was a readable tag. You could output the paths variable by dumping it and choosing what path you needed.
Replacing it with a function that needs extra knowledge and is not readable by default, throws a threshold for templaters.
To speak for myself, this would end-up being a 'magical' tag, where I have no idea what is does, will be copied and pasted from my gist, and being an annoyance, before returning to absolute paths again.
2. The über-readable Twig is used for a reason
The reason why it's a bliss for frontenders and templaters to work in Bolt templates, is because backend is separated from frontend by the lovely Twig language. My Templates are not messy php functions, but readable snippets like {{ record.title }}. There's no learning curve for that. Inserting functions in the templates is a diversion from this philosophy, and in my opinion, is unlike Bolt.
3. A technical issue with the paths variable should be handled in the backend, and not trickle through to the templating.
Knowing the Bolt team, I am sure there is a very valid reason for this change from a technical point of view. Mostly, changes in Symfony versions, new possibilities etc. However. These technical changes should be handeled in the (invisible) backend part, and not end up on the screens of templaters.
Solutions?
For me, keeping the {{PATHS}}
variable alive for getting the paths would be a great option, as is, or as an alias.
An alternative solution @bobdenotter came up with, was making the theme default, so
<img src="{{ asset('images/logo_footer.png', 'theme') }}" alt="Client logo" />
would be simplified to:
<img src="{{ asset('images/logo_footer.png') }}" alt="Client logo" />
Although, as a templater I am still drawing blanks why I should use a function for something as simple as getting a static image from a static folder.
Please discuss! Thanks!
(Won't somebody think of the frontenders!)
RFC