A template compiler transforms each component’s template into JavaScript code that runs in the browser and creates the component’s view. It is one step in the frontend build process, before application code is bundled for deployment. section 1.3.1
The compiler’s practical responsibilities are:
- Process the template belonging to each component. section 1.3.1
- Produce JavaScript that creates the component view in the browser. section 1.3.1
- Feed the resulting application code into later bundling steps, such as app.bundle.js. section 1.3.1
Conditional templates
A template may contain conditional markup, such as a paragraph shown only when hasDiscount is true. Different frameworks express that condition with different template forms, but the compiler turns the component template into browser-executable JavaScript. section 1.3.1
<p v-if="hasDiscount"> You get a discount! </p>
Compare conditional template syntax with the equivalent forms used by other frontend frameworks. section 1.3.1
