0%

Mustache

Mustache

mustache.js is a zero-dependency implementation of the mustache template system in JavaScript. Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.

Useage in Vue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<template>
<div>
<!-- mustache -->
<!-- 1. Basic usage -->
<h2>{{ message }}</h2>

<!-- 2. expression -->
<h2>{{ counter * 10 }}</h2>

<!-- 3. function -->
<h2>
{{ getReverseMessage() }}
</h2>
</div>
</template>

<script>
export default {
name: "App",
data() {
return {
message: "Small Stars",
counter: 100,
};
},
methods: {
getReverseMessage() {
return this.message.split(" ").reverse().join(" ");
},
},
};
</script>

<style></style>

References

-------------The end of this article, thanks for reading-------------