https://github.com/percival33/templating
Templating exploration using mustache.js
https://github.com/percival33/templating
nodejs template
Last synced: 28 days ago
JSON representation
Templating exploration using mustache.js
- Host: GitHub
- URL: https://github.com/percival33/templating
- Owner: Percival33
- Created: 2023-07-06T11:12:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-06T13:30:30.000Z (almost 3 years ago)
- Last Synced: 2025-01-23T06:44:58.281Z (over 1 year ago)
- Topics: nodejs, template
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Mustache.js Templating Exploration
This repository is a simple exploration of Mustache.js, a logic-less templating system in JavaScript. The goal is to understand how to create dynamic templates with Mustache.js.
## Overview
In this project, I use Mustache.js to generate a Mongoose schema from a JSON data file.
The `render.js` file reads the JSON data, uses Mustache.js to render a template, and then outputs a new JavaScript file.
I also have Jest unit tests in place to ensure the rendering process works correctly.
## Example
```shell
npm start render reviewData
> templating@1.0.0 start
> node render.js render reviewData
Rendered template!
```
## Running the Project
1. After cloning the repository, navigate into the project directory and run:
```shell
npm install
```
2. Prepare your own data files and place them inside the `data` directory.
3. To render a template, type:
```shell
npm start render {name_of_your_data.json_file}
```
Replace `{name_of_your_data.json_file}` with the name of your JSON file (without the `.json` extension).
4. That's it! Your rendered template will be output as a new JavaScript file in `output` directory
Feel free to clone this repository and experiment with your own data and templates!