Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

JS-templater Examples

This directory contains example implementations of JS-templater.

Setup

  1. Install dependencies:
npm install express js-templater
  1. Run the example server:
node server.js
  1. Open your browser and navigate to:

Project Structure

examples/
├── server.js              # Express.js server example
├── public/
│   ├── css/
│   │   └── style.css      # Stylesheet
│   └── js/
│       ├── index.js       # Home page template
│       ├── dashboard.js   # Dashboard template
│       ├── profile.js     # Profile template
│       └── simple.js      # Simple template
└── README.md

JavaScript Templates

All JavaScript templates follow the same pattern:

  1. Get the root element: document.getElementById("root")
  2. Parse context data from root.dataset.content (if available)
  3. Render the application using the context data

Customization

You can modify the examples to suit your needs:

  • Update server.js to add new routes
  • Modify JavaScript templates in public/js/ to change the UI
  • Customize styles in public/css/style.css
  • Pass different context data to templates