templatifier

1.0.3 • Public • Published

Templatifier

A command-line tool for transforming HTML templates with custom <cb-templatifier> tags into Django-friendly templates.

Features

  • Replaces custom <cb-templatifier> tags with Django template tags.
  • Supports static file linking and CSRF token insertion.
  • Easy to integrate into build processes or run as a standalone CLI tool.

Installation

You can install templatifier globally using npm:

npm install -g templatifier

Or install it locally in your project:

npm install --save-dev templatifier

Usage

Command Line You can use the templatifier command to transform HTML files directly from the command line. It lets you work with the html files normally within your frontend development environment and when you are ready to ship it, the library transforms it to django.

templatifier -i path/to/input.html -o path/to/output.html

Options

-i, --input : The input HTML file that contains tags. -o, --output : The output HTML file where the transformed content will be saved.

Example

Given an input HTML file like this:

<!-- <cb-templatifier type="loadstatic" />-->
<!DOCTYPE html>
<html lang="en">
<head>
    <!--<cb-templatifier type="static-css" route="css/styles.css" />-->
    <!--<cb-templatifier type="static-script" route="js/app.js" />-->
</head>
<body>
    <!--<cb-templatifier type="csrf_token" />-->
    <!-- Page content -->
</body>
</html>

Running the following command:

templatifier -i src/input.html -o dist/output.html

Would produce the following output:

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <link href="{% static 'css/styles.css' %}" rel="stylesheet">
    <script defer="defer" src="{% static 'js/app.js' %}"></script>
</head>
<body>
    {% csrf_token %}
    <!-- Page content -->
</body>
</html>

License

This project is licensed under the MIT License.

About

We are www.cubode.com an startup focussed on No Code, AI and OpenSouce.

Templatifier has been developed with 💙 for the community

Package Sidebar

Install

npm i templatifier

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

10.8 kB

Total Files

6

Last publish

Collaborators

  • cubode