I have a web app that I am porting over from Slim v3 framework. The logic part has been extremely straight-forward. My problem has been converting the Twig view templates to the F3 templates. Generally speaking it's been relatively easy, but the one place I'm having tremendous issue is when trying to build strings for Materialize classes.
For instance, suppose my contact form validation passes back a message_err that states, "The name field must be at least 3 characters."
The Slim app, utilizing Twig's template engine, would check to see if data.name_err was empty, if not it would create a new messageName by concatenating 'data-err="' with data.name_err and this would then be used to display an error state in a Materialize form. Here's the code:
<div class="input-field">
<label for="name">Name:</label>
{% if data.name_err %}
{% set messageName = 'data-error="'~data.name_err~'"' %}
{% endif %}
Enter code here...
Is there any way to perform a similar concatenation in F3's built-in template engine? I have tried many different ways, and it seems to always throw a syntax error. It seems like I should be able to do something like:
<set msg="data-error=" {{ @data.name_err }} "></set>
Enter code here...
Or this:
<set msg="{{ data-error=" @data.name_err "}}"></set>
Enter code here...
But they both throw errors. There also doesn't seem to be a way to escape characters in the string, which is why I was attempting to use the ASCII characters for the quotes and also the equals sign at one point.
Any ideas would be greatly appreciated.