Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

ArturGuedes/minimal-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Minimal Replace

A lightweight templating solution for HTML that enables dynamic content insertion using a simple {{::variable}} syntax. Keep your HTML clean and maintainable by separating content from structure.

Minimal Replace version Minimal Replace downloads

Features

  • Simple Syntax: Use {{::variable}} to insert dynamic content
  • Clean Separation: Keep HTML structure separate from content data
  • Multiple Usage Options: CDN for live preview or Brackets extension for unified file generation
  • HTML Support: Accepts HTML expressions within variable values
  • Lightweight: Minimal overhead for maximum performance

Installation & Usage

Basic Syntax

Variables are defined using the {{::variableName}} syntax and replaced with corresponding values from the JavaScript data object:

<div class="card">
  <h1>I'm {{::name}}</h1>
  <h2>from {{::planet}}</h2>
</div>

Option 1: CDN (Live Preview)

For dynamic content replacement in the browser, add the following scripts to your HTML <body>:

<script>
  mr_data = {
    name: "Arthur Phillip Dent",
    planet: "Earth",
  };
</script>
<script src="https://arturguedes.github.io/minimal-replace/js/minimalreplace.min.js"></script>

Option 2: Brackets Extension (Unified File Generation)

The Brackets extension generates a unified HTML file by processing your templates and data files.

  1. Install the Minimal Replace extension in Adobe Brackets
  2. Use Minimal > Setup Minimal Replace structure to create the project structure
  3. Define your data in JavaScript files with the same name as your HTML templates

Project Structure

.
├── mr-structure/
│   ├── example.html        # Template with {{::variable}} syntax
│   ├── example.js          # Data file with mr_data object
│   └── ...
├── example.html            # Generated unified HTML file
└── ...

Important Notes

  • The mr_data object supports HTML expressions within variable values
  • When using HTML with quotes, escape internal quotes with backslashes:
    mr_data = {
      link: '<a href="#">Link</a>',
    };

License

This project is licensed under the GNU General Public License v3.0.

About

A lightweight HTML templating solution using simple {{::variable}} syntax

Topics

Resources

License

Stars

Watchers

Forks

Contributors