All Projects → metalsmith → Metalsmith In Place

metalsmith / Metalsmith In Place

🏙️ A metalsmith plugin for in-place templating

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Metalsmith In Place

be-course-19-20
🎓 Backend · 2019-2020 · Curriculum and Syllabus
Stars: ✭ 18 (-65.38%)
Mutual labels:  templating
Handlebars Layouts
Handlebars helpers which implement layout blocks similar to Jinja, Nunjucks (Swig), Pug (Jade), and Twig.
Stars: ✭ 336 (+546.15%)
Mutual labels:  templating
Dotdrop
Save your dotfiles once, deploy them everywhere
Stars: ✭ 813 (+1463.46%)
Mutual labels:  templating
templating
The Templating component provides all the tools needed to build any kind of template system.
Stars: ✭ 985 (+1794.23%)
Mutual labels:  templating
Markserv
🏁 serve markdown as html (GitHub style), index directories, live-reload as you edit
Stars: ✭ 304 (+484.62%)
Mutual labels:  templating
Levant
An open source templating and deployment tool for HashiCorp Nomad jobs
Stars: ✭ 510 (+880.77%)
Mutual labels:  templating
view
Template Engine For AdonisJS
Stars: ✭ 13 (-75%)
Mutual labels:  templating
Cv Maker
simple elegant markdown based resumes
Stars: ✭ 1,003 (+1828.85%)
Mutual labels:  templating
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+521.15%)
Mutual labels:  templating
Faas Cli
Official CLI for OpenFaaS
Stars: ✭ 633 (+1117.31%)
Mutual labels:  templating
flintcms
🔥💥 A Node.js CMS
Stars: ✭ 45 (-13.46%)
Mutual labels:  templating
Grips
Simple-logic templates
Stars: ✭ 289 (+455.77%)
Mutual labels:  templating
Rocker
Java 8 optimized, memory efficient, speedy template engine producing statically typed, plain java objects
Stars: ✭ 609 (+1071.15%)
Mutual labels:  templating
yaproq
A templating language in Swift
Stars: ✭ 57 (+9.62%)
Mutual labels:  templating
Carvel Ytt
YAML templating tool that works on YAML structure instead of text
Stars: ✭ 816 (+1469.23%)
Mutual labels:  templating
polymerase
A tool for populating templates with environment variables and Vault values
Stars: ✭ 84 (+61.54%)
Mutual labels:  templating
Microwebsrv
A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
Stars: ✭ 420 (+707.69%)
Mutual labels:  templating
Yglu
Yglu ᕄ !? - YAML glue for structural templating and processing
Stars: ✭ 51 (-1.92%)
Mutual labels:  templating
Jmmasw
Just make me a static website
Stars: ✭ 13 (-75%)
Mutual labels:  templating
Plush
The powerful template system that Go needs
Stars: ✭ 623 (+1098.08%)
Mutual labels:  templating

metalsmith-in-place

build status greenkeeper

A metalsmith plugin for transforming your source files

This plugin allows you to render templating syntax in your source files. It uses file extensions to infer which templating engine to use. So files ending in .njk will be processed as nunjucks, .md as markdown, etc. You can even chain transformations by appending multiple extensions, which will be processed right-to-left.

If you want to wrap your source files in a common template, you can use metalsmith-layouts. For usage examples check out our wiki. Feel free to contribute an example if anything is missing, or update the existing ones. For support questions please use stack overflow or our slack channel. For templating engine specific questions try the aforementioned channels, as well as the documentation for jstransformers and your templating engine of choice.

Installation

$ npm install metalsmith-in-place

This plugin uses jstransformers to transform files. Since there are a lot of jstransformers we don't install them automatically, so you'll also need to install the appropriate jstransformers.

For example, to render markdown you would install jstransformer-markdown. To render handlebars you would install jstransformer-handlebars. See the jstransformer organisation for all available jstransformers and this dictionary to see which extensions map to which jstransformer.

Options

You can pass options to metalsmith-in-place with the Javascript API or CLI. The options are:

  • pattern: optional. Only files that match this pattern will be processed. Accepts a string or an array of strings. The default is **.
  • engineOptions: optional. Use this to pass options to the jstransformer that's rendering your files. The default is {}.
  • suppressNoFilesError: optional. The no-files-to-process error will be suppressed. The default is false.
  • setFilename: optional. Some templating engines, like pug, need a filename property to be present in the options to be able to process relative includes, extends, etc. Setting this option to true will add the current filename to the options passed to each jstransformer. The default is false.

pattern

Only files that match this pattern will be processed. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-in-place": {
      "pattern": "blog/**/*"
    }
  }
}

Would only process files within the ./src/blog folder, because the pattern is relative to your source folder. See multimatch for further details.

engineOptions

Use this to pass options to the jstransformer that's rendering your templates. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-in-place": {
      "engineOptions": {
        "cache": false
      }
    }
  }
}

Would pass { "cache": false } to each used jstransformer.

suppressNoFilesError

metalsmith-in-place exits with an error if it can’t find any files to process. If you’re doing any kind of incremental builds via something like metalsmith-watch, this is problematic as you’re likely only rebuilding files that have changed. This flag allows you to suppress that error. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-in-place": {
      "suppressNoFilesError": true
    }
  }
}

Would suppress the error if there aren't any files to process. Note that when this option is turned on, if you're logging debug messages, you’ll still see a message denoting when there aren't any files for metalsmith-layouts to process.

setFilename

Set this option to true if you want to pass the current filename to each jstransformer. The default is false. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-in-place": {
      "setFilename": true
    }
  }
}

Would overwrite engineOptions.filename with the absolute path for the file that's currently being processed, and pass that to the jstransformer. For now we're just passing filename, but if you encounter a jstransformer that requires a different property, like path or something else, let us know and we can add it.

Errors and debugging

If you're encountering problems you can use debug to enable verbose logging. To enable debug prefix your build command with DEBUG=metalsmith-in-place. So if you normally run metalsmith to build, use DEBUG=metalsmith-in-place metalsmith (on windows the syntax is slightly different).

No files to process

There are several things that might cause you to get a no files to process error:

  • Your pattern does not match any files
  • None of your files pass validation, validation fails for files that:
    • Have no extension
    • Are not utf-8
    • Need a jstransformer that hasn't been installed

Credits

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].