filetype-template-tags v1.0.1
filetype-template-tags
Template literal tags that do (almost) nothing except provide a type so editors can syntax highlight properly.
The tag also runs the template text through Dedent to remove unnecessary whitespace.
Motivation
The vim plugin vim-tagged-template will properly highlight template literals only if they're tagged. An empty tag function i.e. function(template) { return template; }
mutilates the template's type, so a more complex solution is necessary. A tag that actually does nothing exists, but isn't suitable for easy inclusion for many filetypes
Usage
const { http, md } require('filetype-template-tags');
let httpSnippet = http`
<h1>Hello, World!</h1>
`
let mdSnippet = md`
# Hello, World!
`
Available filetypes
All the default filetypes are listed in the source. If you think another type should be added, just add it to the array and write a quick PR.
Custom filetypes
Custom filetype tags can be created as follows. Any number of inputs can be given, but they must be strings.
const { http, md, arbitraryType, type2 } = require('filetype-template-tags')('arbitraryType', 'type2')
let arbitraryTypeSnippet = arbitraryType`
Hello, World!
`
let type2Snippet = type2`
Hello, World!
`
Behavior
All filetype tags are just wrappers around Dedent.