Skip to content

Instantly share code, notes, and snippets.

View jjantschulev's full-sized avatar
🦀
thinking

Jordan Jantschulev jjantschulev

🦀
thinking
View GitHub Profile
@jjantschulev
jjantschulev / sketch.js
Created February 9, 2019 11:31
P5.js Maze Generator
const mapWidth = 50;
const mapHeight = 50;
const path = [];
const stack = [];
const map = [];
let currentIndex = 0;
let mazeGenFinished = false;
let gridSizeX = 10;
let gridSizeY = 10;
@jjantschulev
jjantschulev / html-templater.js
Last active December 1, 2019 23:51
Simple HTML Templating language parser. Loop support.
const path = require("path");
const fs = require("fs");
const { promisify } = require("util");
const fsReadFile = promisify(fs.readFile);
const LOADED_FILES = {};
const COMMANDS = ["include", "insert", "loop", "endloop", "if", "endif"];
async function readFile(filename, options) {
if (process.env.ENV === "dev") {
@jjantschulev
jjantschulev / README.md
Last active May 28, 2020 03:58
Fast, Simple Templating Engine. Works with any type of text. Built in node.js.

How To Use

All expressions in FastplateJS are wrapped by !( expression ) except for the end-block expression: !/

In fastplate you can do these things:

  • Insert value into text: !(path.to.value) This is the json path to your value from the passed data object. It can also be the iterator variable when inside a loop. Or it can be a function. (this function must have been defined in the data object passed to the fastplate(text, data) call).
    • If it is a function you can pass arguments after the initial function name. EG: !(load body).
    • You can also pass variables that are in scope to the function by using $. EG: !(renderAsName $user.name big). In this case the actual user name will be passed as the first argument and the literal string "big" will be passed as the second.
0x5146baf0fa69f81b496fe82ed36c8e53e9640a5a99bd4c0fa5125a8310eb479c01152150594cbaba2fbfefd9c45a252acafff03541071e74983283616b278c701c