bhylu.com

Advertisements

Vue Template Syntax

Render text as text and keep expressions small.

How it works

Double braces interpolate a value into text. Vue escapes that value rather than interpreting it as HTML. Templates allow JavaScript expressions, but a long expression full of parsing and branching is difficult to review. Move complex transformations into a computed value or a named function. The packet label below intentionally contains angle brackets to make the text boundary visible.

Run the code

Use a separate empty learning folder with Node 22.12+ in the 22 series. The reviewed Node version is 22.15.1. Save all files below with their exact relative paths; downloads may keep only the basename, so create src and any tests folders as listed. This project pins Vue 3.5.44 and Vite 7.3.1. Run npm install, then npm run dev and open the local address Vite prints.

Bhylu has no Vue playground. SFCs, npm imports and routing need this local project; do not paste them into the plain HTML or JavaScript editor. Apache, MySQL and changes to Bhylu server settings are not required. The application is a fictional seed-swap learning fixture.

Example

src/App.vue

<script setup>
const label = "<Bean packet>";
</script>

<template>
  <main>
    <h1>Riverside seed swap</h1>
    <p data-result>{{ label }}</p>
  </main>
</template>

Expected result

The page displays the literal text <Bean packet>.

The label does not become a custom element. That is important when a value comes from another person or an external response. Escaped text still needs an appropriate application meaning, but it avoids treating a string as executable template or markup.

Check APIs and version differences in the official Vue guide.