GithubHelp home page GithubHelp logo

bracketing / bracket Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 118 KB

⚒ Bracket is an Elegant static site generator (in preview)

Home Page: https://bracket.ink

License: MIT License

Python 100.00%
python bracket static-site-generator jinja2 flask

bracket's Introduction

Bracket

Bracket is an Elegant static site generator. It encapsulates Jinja2. Its biggest highlight is to render the static pages in the form of view function, and support real-time debugging. It can also support CSS framework, international routing and more functions through ecological extension.

The project is being updated continuously, and the official version has not been completed yet

Installing

Install and update using pip:

$ pip install bracket

A Simple Example

from bracket import WebSite
from jinja2 import Template

app = WebSite(__name__)

@app.pages("/")
def helloworld(context):
    return context({
    "title":"Welcome to Bracket",
    "content":Template('''
        <h1>{{ messages }}</h1>
        <img src="{{ bracket.res('/logo.png')}}">
    '''),
    "resources":{
        "messages":"Welcome to Bracket"
    }
})

app.dispatch("/")
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="Bracket & Jinja2 ">
    
    <title>Welcome to Bracket</title>
</head>
<body>
    <div id="bracketapp">
    
        <h1>Welcome to Bracket</h1>
        <img src="/static/logo.png">
        
    </div>
</body>
</html>

Contributing

How to contribute to this project, report problems, and build a development environment, please refer to the contribution guide

Links

License

The project is open source under MIT license in GitHub Community. No one is allowed to infringe the copyright. Please follow LICENSE

bracket's People

Contributors

ceorleorn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ceorleorn

bracket's Issues

#1 Project Development Guide

Project Overview

Bracket is an Elegant static site generator. It encapsulates Jinja2. Its biggest highlight is to render the static pages in the form of view function, and support real-time debugging. It can also support CSS framework, international routing and more functions through ecological extension.

Pages

Use the view function to render the static interface, and the context will be activated when the view function is running.

from bracket import (WebSite, pages, resources)

app = WebSite(__name__)

@app.pages("/")
def helloworld():
    resources.loader()
    content = pages({
    "title":"Welcome to Bracket",
    "content":Template('''
        <h1>{{ messages }}</h1>
        <img src="{{ bracket.res('/logo.png')}}">
    '''),
    "resources":{
        "messages":"Welcome to Bracket"
    }})
    return content.encode("utf-8")

app.dispatch("/")

Route

When converting the result of view function to static file, route escape function is used

escape("/") # index.html
escape("/bugs") # bugs.html
escape("/u/{{ user.id }}", user=userlist) # /u/1.html, /u/2.html ...

Extension

Users are free to create ecological extensions and publish them to https://pypi.org. Extension is essentially a library.

#bracket_hello.py

from bracket import Extension
from jinja2 import Template

class Hello(Extension):
    def __init__(self,configs):
        self.configs = configs
        self.all = {"createLink": self.createLink}

    def createLink(self,text,link):
        return Template('''<a href="{{ link }}">{{ text }}</a>''').render(text=text,link=link)

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.