2.6 KiB
2.6 KiB
Twig preview
Twig templates are coloured (HTML with Twig's tags) and have Code / Preview in the editor (and Code / Both / Preview in the quick editor).
What the preview does
- Lays the page out like Symfony would:
{% extends %},{% include %}, blocks andparent()are followed through the project'stemplates/(and@Bundle/paths). - Loads the project's CSS:
asset(),importmap(), Webpack Encore entries. Layout + CSS turns this off to see the template alone. - Function calls (
{{ form(f) }},{{ importmap('app') }}) are not printed as text;path()/url()become#. - It is a preview of the markup: variables have no values and no PHP runs. For the real page, pick a route (next section).
The real page: pick a route
Next to Fit / Desktop / Tablet / Phone, the route selector lists every route of the app (name, methods, path), read from the
controllers. The routes whose controller renders THIS template (render('…'), #[Template('…')]) come first, then the other GET routes,
then the rest. The first route that renders the template is chosen by itself; Static (no PHP) is the markup preview described above.
- The preview then shows the page the running local site sends for that route: the controller's data, the site's real CSS (linked
stylesheets,
@import,url()) and pictures put inside it (only the site's own address is ever asked), scripts off unless Scripts is on. It is fetched again each time a file is saved (typing alone changes nothing: the site reads the saved files). - A route with parameters (
{id},{slug}…) shows one small input per parameter. For an entity (Book $bookconverted from{id}) the first ids of its table are suggested, and the first one filled in, when the Database window has a connection open; otherwise type the value. What you typed is remembered, and so is the route chosen, per template. - My session fetches the page with the cookies of the HTTP Client (a login made there); without it the page is asked as a stranger and no cookie is sent nor kept.
- A
500shows Symfony's own error page, as sent. A redirect to a sign-in page shows that page, with a Use my session button. - The site is not running: the static preview is shown meanwhile, with a Start the site button (Run > Serve the site); the page appears by itself once the site answers.
Navigation
Ctrl+click on a template name ('base.html.twig', @Bundle/x.html.twig, /build/app.css) opens the file; translation keys lead to
translations/*.yaml (YAML).