3.0.0 • Published 3 years ago

@vimlet/meta v3.0.0

Weekly downloads
54
License
MIT
Repository
github
Last release
3 years ago

npm Travis (.org) branch Codacy grade GitHub

It is a tool that generate files from templates.

Features

  • Data binding.
  • Inheritance templates.
  • Glob patters to search for template files.
  • Watcher to look for changes and update files on the fly.

You can access the source code at vimlet/meta

Installation

npm install @vimlet/meta

Usage

  • meta.parse(template, options, callback);

    Returns the result of given template.

  • meta.parseTemplate(template, options, callback);

    Returns the result of given template file.

  • meta.parseTemplateGlob(include, options, callback);

    Returns an object with the result. {"relativePath":"", "result":""}

  • meta.parseTemplateGlobAndWrite(include, output, options, callback);

    Write the results to output folder while keeping files structure.

  • meta.watch(include, output, options);

    Do parseTemplateGlobAndWrite and keep looking for changes.

    options

    { "exclude": "glob patterns", "data": {}, "clean": false }

    • exclude: Used to skip files that you don't want to parse.
    • output: Directory where files will be written using parseTemplateGlobAndWrite.
    • data: Data to be bind.
    • clean: Empty output directory before parse.

Command mode:

  • vimlet-meta -i include -o output -e exclude -d data -c clean

    Calls meta.parseTemplateGlobAndWrite

  • vimlet-meta -i include -o output -e exclude -d data -c clean -w

    Calls meta.watch

Extra

vimlet-meta remove comments if there are only meta code within it.

<% teamplate("anothertemplate.vmi")%>

produce the same result as

// <% teamplate("anothertemplate.vmi")%>

or

/ <% teamplate("anothertemplate.vmi")%> /

This behaviour can be avoided using -p.

Example

  • Template: Hello I'm a template <%echo("Raw text");%>

  • Result: `Hello I'm a template Raw text

  • Template: Hello I'm a template <% data.name %>

  • Data: {"name":"vimlet-meta"}

  • Result: Hello I'm a template vimlet-meta
  • Template1: Hello I'm a template <%template(template2.vmi)%>

  • Template2: I'm another template

  • Result: Hello I'm a template I'm another template

Data binding

One of the meta advantages is the ability to bind data from a json. IE:

Template:

Hello <%= data.name%>

Data:

{"name": "Peter"}

Result:

Hello Peter

File extension

We use .vmt for vimlet meta templates and .vmi for vimlet meta imported in our imported templates but any extension is welcome.

Note that meta respects file extension if it is included in template name:

  • index.html.vmt after parsed will be written as index.html.

License

vimlet-meta is released under MIT License. See LICENSE for details.

3.0.0

3 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.5

5 years ago

2.4.4

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago