Coder Social home page Coder Social logo

markdownbars's Introduction

markdownbars

Harndlebars on the cmdline with markdown helpers.

Usage: markdownbars -i input.hbs.md [-d data] [-o output.md]

Options:
  --help, -h    Generate help                         [boolean] [default: false]
  --version     Show version number                                    [boolean]
  --input, -i   Input file                                   [string] [required]
  --output, -o  Output file                                             [string]
  --data, -d    Additional JSON data to pass into the template
                                                        [string] [default: "{}"]

install

npm install -g markdownbars

helpers

Markdownbars comes with a few convenience helpers useful for generating markdown files:

include

Usage:

{{include 'filename.tpl.md' context=obj noeval=true}}

Includes another file. You can optionally pass a context named parameter to change the context. The file will receive the data from the context as variables.

The noeval argument will disable evaluation of the file as a handlebars template - it will be included verbatim.

filetree

Usage:

{{filetree relativePath padding}}
  • relativePath - the path of the directory relative to current file
  • padding - how much to pad each item in the tree except the first one

Example:

{{filetree '.dir' 2}}

Will generate a tree list of all markdown files in 'dir'

glob

Usage:

{{#glob '*.md'}}
  The file is {{@file}}
{{glob}}

Will glob each file as specified in the glob. Double star globs are also supported. For each file found it will execute the inner block with the private variable @file containing the relative path.

The globbing is done relative to the current file's directory.

frontmatter

Usage

{{frontmatter 'filename.md' 'fieldName'}}

Reads the frontmatter of the specified file and access the desired field

basename

Usage:

{{basename filename ext}}

Acts just like node's path.basename (will strip the file directory and specified extension)

file-exists

Typical usage:

{{#if (file-exists 'relative-path')}}
  show something about this file
{{if}}

Will return true if the file exists. Typically only useful as a sub-expression.

concat

Typical Usage

{{#if (file-exists (concat @file 'OtherSegment'))}}
  some output
{{if}}

Concatenate multiple strings into one. Normally this is not needed in handlebars, however in sub-expressions it may be necessary to pass a different argument

equals

Just a regular loose equality check, useful in sub-expressions

not

Inverts a boolean, e.g.

{{#if (not (file-exists 'file'))}}
  Show content if file does not exist
{{if}}

and

Logical and, supports multiple operands

or

Logical OR, supports multiple operands

left-pad

Example Usage:

{{left-pad 2 (include 'othertemplate.md')}}

Useful to pad content produced by other helpers by the appropriate amount e.g. for lists.

cwd

Returns the current file's working directory, relative to the entrypoint file.

markdownbars's People

Contributors

spion avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.