Giter Site home page Giter Site logo

blup's Introduction

Blup

Blup is a small program which turns a JSON file into a HTML file based on a Jinja template file. The program needs a json source file and a Jinja html template.

Installation

$ pip install blup

Usage

You need to prepare two files :

  • a JSON file with all the data you'd like put into your template. The root element needs to be an object (not a list).
  • a template file following Jinja's rules. You can check them out on their doc.

Then, once everything is prepared, you need to run :

$ blup template.html source.json >> output.html

You can also run blup as a server (constantly listening for json modifications). For that, use this command :

$ blup template.html source.json -o output.html --serve

Example

Imagine you'd like to build a small HTML page showing your resume. You start by writing all the informations needed in a json file.

{
  "name": "César Pichon",
  "occupation": "Student in computing sciences",
  "studies": [
    {
      "name": "Bachelor of Social sciences",
      "date": "2018-2021"
    },
    {
      "name": "Bachelor of Computing sciences",
      "date": "2021-2023"
    }
  ]
}

Then, you write a Jinja template :

<!DOCTYPE html>
<html>
  <head>
    <title>Resume</title>
  </head>
  <body>
    <h1>{{ name }}</h1>
    <h2>{{ occupation }}</h2>
    <p>
      <h3>Studies</h3>
      <ul>
        {% for diploma in studies %}
          <li><b>{{ diploma.name }}</b> - {{ diploma.date }}</li>
        {% endfor %}
      </ul>
    </p>
  </body>
</html>

Finally, your run blub and get the following result :

<!DOCTYPE html>
<html>
  <head>
    <title>Resume</title>
  </head>
  <body>
    <h1>César Pichon</h1>
    <h2>Student in computing sciences</h2>
    <p>
      <h3>Studies</h3>
      <ul>
          <li><b>Bachelor of Social sciences</b> - 2018-2021</li>
          <li><b>Bachelor of Computing sciences</b> - 2021-2023</li>
      </ul>
    </p>
  </body>
</html>

blup's People

Contributors

16arpi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.