Questions tagged [twig]

Twig is a modern, fast, flexible, and secure templating engine for PHP.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

Twig macro to generate a table

Basically, I'm lazy. And so, since I don't want to write multiple times the same table HTML, I've made a very ... convoluted macro. ...
3
votes
1answer
374 views

Simple CSS minifier for twig, with basic caching

On part of a project, I have some CSS being read using twig's source() function. But sending a huge chunk of CSS is not optimal. To reduce the size of the HTML, I'...
4
votes
1answer
183 views

Javascript contact form validation code

I'm a UI / UX Designer trying to sharpen my JS skills. I wanted someone else to check this code snippet and maybe have a Pro tip to improve or shorten it. Javascript: ...
3
votes
1answer
509 views

Raw filter with ternary operator for html class attribute

I've been trying to figure out how to stop Twig escape using the following code, which I feel is a little nicer with the succinct ternary operator. I hope someone can confirm I'm using the correct ...
1
vote
1answer
37 views

Should I include a view for each message?

For now, I have two views using Twig: messages.html.twig item.html.twig The first one is the view which displays all of the users' posts in my forum. When a user post a new message, it's done via ...
2
votes
1answer
313 views

Receiving data from a database

I am learning OOP using PHP5 and I wrote two simple classes for receiving data from a database using the dependency injection pattern and rendering a grid with Twig. Does this code have sense for OOP ...
4
votes
1answer
972 views

Optimizing a table - Twig, CSS

I have a table with forms in two colors - the first row is one color, the second is the other. Can you please tell me if there is a way to optimize my code (such as with this)? I have two CSS classes:...