Appearance
π§± Embedding HTML in WBC-Routes2 Routes β
WBC-Routes2 makes embedding HTML content effortless β no extra component imports or wrappers needed. Whether itβs a block of semantic content, inline styling, or UI fragments, WBC takes care of rendering it inside Vue routes.
πΉ Basic Static HTML Injection β
You can use plain HTML strings directly in the route's item array.
js
{
path: "/static-html",
name: "StaticHTML",
component: WBC,
props: {
item: [
"<h2>Welcome to the Static HTML Page</h2>",
"<p>This content was defined directly inside the route definition.</p>",
"<div class='info-box'>HTML + WBC = β€οΈ</div>"
]
}
}This is ideal for short notice content, announcements, or UI overlays.
πΈ Using HTML with Component Options β
You can specify comp: 'div' or any valid element and use the options.html field.
js
{
path: "/html-block",
name: "HTMLBlock",
component: WBC,
props: {
item: {
comp: "div",
options: {
class: "pa-5 grey lighten-3",
html: "<h3>Block Content</h3><p>This is injected via component options.</p>"
}
}
}
}This gives you more control and supports props like class, style, events, and more.
π Styled HTML Elements with WBHtml Syntax β
You can also use WBHtml-style shortcuts:
js
[
"div__Welcome to WBC-Routes2!|green text-white",
"li__Step 1: Add your route|blue",
"li__Step 2: Embed content|orange",
"li__Step 3: Launch your app π|teal"
]Each string is parsed and styled based on the pipe-split syntax.
π Loading HTML from Remote Source β
Combine HTML and remote loading like this:
js
{
path: "/remote-html",
name: "RemoteHTML",
component: WBC,
props: {
item: {
comp: "div",
options: {
src: "https://example.com/snippets/promo.html",
class: "pa-5 border shadow-sm"
}
}
}
}WBC fetches the content and places it inside a div component.
ποΈ Dynamic HTML with Event Bindings β
Using dive: true, you can attach interactivity:
js
{
path: "/interactive-html",
name: "InteractiveHTML",
component: WBC,
props: {
item: {
dive: true,
comp: "div",
options: {
html: "<button class='btn' id='my-btn'>Click me</button>",
on: {
click: (that) => () => {
alert('Button clicked inside HTML block!');
}
}
}
}
}
}This turns plain HTML into an interactive Vue-managed component.
π§© Complex Nested Layout β
Use multiple HTML components with Vue-like structure:
js
{
path: "/html-layout",
name: "HTMLLayout",
component: WBC,
props: {
item: [
{ comp: "div", options: { html: "<h2>Header</h2>", class: "header" }},
{ comp: "section", options: { html: "<p>Section content goes here...</p>", class: "section-body" }},
{ comp: "footer", options: { html: "<p>Footer content</p>", class: "footer grey--text" }}
]
}
}Each piece is rendered as a structured VueDOM node, supporting modular layout creation.
π§ Best Practices β
| Case | Recommendation |
|---|---|
| Small inline snippets | Use plain HTML strings |
| Large HTML blocks | Use comp: 'div' + options.html |
| Style + Behavior | Use dive: true with on handlers |
| External HTML content | Use options.src (supports CORS) |
| Maintainable layout | Use array of structured components |