vue-sprintf-components
Sprintf with vue components
Demo
Install
Via Yarn:
yarn add vue-sprintf-components
Via NPM:
npm i vue-sprintf-components
Quick start
Hello! <!-- render: component say: <button>hello!</button> -->
Usage
The component takes 2 props: text
and silence
- text
- type:
String
- required:
true
Any string with placeholders{0}
and named placeholders{name}
- type:
- silence
- type:
Boolean
If silence false, if there are not enough slots for placeholders, there will be an error
- type:
- placeholders
- type:
Array|Object
Fallback placeholders if slots not enoght
- type:
Example
With args placeholders
Hello!
To render
component say: Hello!
With named placeholders
Hello! Bye-Bye!
To render
component 'a' say: Hello! and component 'b' say: Bye-Bye!
With named placeholders + fallback placeholders
Hello!
To render
component 'a' say: Hello! and component 'b' say: Bye-Bye!
With list placeholders + fallback placeholders
Hello!
To render
component '0' say: Hello! and component '1' say: Bye-Bye!