konstrui

command module
v0.0.0-...-43773a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

README

Konstrui Go Report Card

web templating engine for static websites, written in Go lang

konstrui

Example

See the full example on https://github.com/arnaucode/konstrui/tree/master/example
  • Simple project structure example:
webInput/
    konstruiConfig.json
    index.html
    templates/
        userTemplate.html
        userTemplate.json
  • Set the html file:
<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

<konstrui-template html="templates/userTemplate.html" data="templates/userTemplate.json"></konstrui-template>

</body>
</html>

  • Set the template file:
<div class="class1" id="user[[i]]">
    <div id="username[[i]]" class="class2">{{username}}</div>
    <div id="description[[i]]" class="class2">{{description}}</div>
    <div class="class2">{{phone}}</div>
</div>
  • Set the template data file:
[{
        "username": "Michaela Doe",
        "description": "Hi, I'm here to code",
        "phone": "456456456"
    },
    {
        "username": "John Doe",
        "description": "Hi, I'm here",
        "phone": "123456789"
    },
    {
        "username": "Myself",
        "description": "How are you",
        "phone": "no phone"
    }
]
  • Set the configuration file konstruiConfig.json in the webInput directory:
{
    "title": "Web example",
    "author": "arnaucode",
    "github": "github.com/arnaucode",
    "website": "arnaucode.com",
    "files": [
        "index.html",
        "projects.html",
        "app.css"
    ]
}
  • Execute konstrui
./konstrui
  • Output:
<!DOCTYPE html>
<html>

<body>
    <h1>Heading</h1>
    <p>Paragraph.</p>
    <div class="class1" id="user0">
        <div id="username0" class="class2">Michaela Doe</div>
        <div id="description0" class="class2">Hi, I'm here to code</div>
        <div class="class2">456456456</div>
    </div>
    <div class="class1" id="user1">
        <div id="username1" class="class2">John Doe</div>
        <div id="description1" class="class2">Hi, I'm here</div>
        <div class="class2">123456789</div>
    </div>
    <div class="class1" id="user2">
        <div id="username2" class="class2">Myself</div>
        <div id="description2" class="class2">How are you</div>
        <div class="class2">no phone</div>
    </div>
</body>

</html>

Features

Import templates

<konstrui-template html="template.html" data="template.json"></konstrui-template>

Load values:

{{username}}

Number of iterations:

User [[i]]

Subobjects:

<p konstrui-repeat="users">
    {{user.username}}
</p>

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL