07: Directive Shorthand
Some directives can be abbreviated with shorthand syntax.
::
is alias ofx-controller _
.:xxx
is alias ofx-bind:xxx
.@yyy
is alias ofx-on:yyy
.
<body> <section class="todoapp"<!DOCTYPE html>
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1" > <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/todomvc-app-css@2.1.2/index.css" > <script src="https://x-ninja.org/assets/js/o_o.js"></script> <script src="https://x-ninja.org/assets/js/flux._.js"></script> <title>TODOs @x-ninja</title> </head>x-controller _ ::> <header class="header"> <h1>todos</h1> <input class="new-todo" autofocus autocomplete="off" placeholder="What needs to be done?" x-on:@change="addTodo({newTodo: launcher$.value})" x-callbacks="{ change (_) { _.$.value = '' } }" > </header> <section class="main">x-state="{
todos: [], }" x-invocations="{ addTodo (_, payload, meta) { const newTodo = payload.newTodo.trim() if (!newTodo) { return } this.todos.push({ title: newTodo, completed: false }) }, }"<ul class="todo-list" x-each="todo in todos" > <li class="todo" x-bind:class="{ completed: todo.completed, }" ><input id="toggle-all" class="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as complete</label></li> </ul> </section><div class="view">
<input class="toggle" type="checkbox" x-model="todo.completed" > <label>{{ todo.title }}</label> <button class="destroy"></button> </div> <input class="edit"></section> </body> </html><footer class="footer">
<span class="todo-count"> <strong>3</strong> items left </span> <ul class="filters"> <li><a href="#/all" class="selected">All</a></li> <li><a href="#/active">Active</a></li> <li><a href="#/completed">Completed</a></li> </ul> <button class="clear-completed"> Clear completed </button> </footer>