A Flexible Static Site Generator for Python
Project description
Render Engine JSON
JSON Parser and Collection Module for Render Engine
Installation
pip install render_engine_json
Usage
The render-engine-json
extends render-engine to allow you to build pages and collections using JSON.
The JSONPageParser
class can be used to parse a single JSON page and the JSONCollection
class can be used to parse a single collection of JSON pages.
NOTE The
JSONCollection
class is designed to work with a single JSON file that contains an array of JSON Objects or a JSON Hash where the keys are the slugs. If you want to work with multiple JSON files you can use a regularCollection
and theJSONPageParser
as the parser.
Single JSON Page Entry
To create a json entry you will need the JSONPageParser
class as the Parser for your Page
Object.
You can pass the page a json string or a json file path.
As a string
from render_engine import Page, Site
from render_engine_json import JSONPageParser
site = Site()
json_page = """
{
"title": "My JSON Page",
"content": "This is my json page"
}
"""
@site.page
class JSONStringPage(Page):
parser = JSONPageParser
content = json_page
As a file
@site.page
class JSONFilePage(Page):
parser = JSONPageParser
content = "path/to/json/file.json"
JSON Collection
To create a JSON collection you will need the JSONCollection
Object.
You can pass the collection a json string or a json file path.
As a string
from render_engine import Site, Collection
from render_engine_json import JSONCollection, JSONPageParser
site = Site()
json_collection = """
[
{
"title": "My JSON Page",
"content": "This is my json page"
},
{
"title": "My JSON Page 2",
"content": "This is my json page 2"
}
]
"""
@site.collection
class JSONStringCollection(Collection):
parser = JSONPageParser
content = json_collection
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for render_engine_json-2023.1.0a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d1a9092a1cd9106cca04a5cb65be7e7abcd1fa97f51a6fb5c4d8c78c310c9d |
|
MD5 | 5da1ccfac3ef5d84c82becda154886e1 |
|
BLAKE2b-256 | 5340af21130f4392b6a7420b212768a35569131ffd5486f4d7c624552ba26cc6 |
Hashes for render_engine_json-2023.1.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e14947e42878ad8695a5815dde18e606dd48a270416beb21d09957244a8bf8d4 |
|
MD5 | 2560c223617168622132f1564197d2b4 |
|
BLAKE2b-256 | 8eedc3ac6e5e594fa48a5ceb7b73184239c5f453058fda3ad0329f8ef172abf7 |