ham

package module
v0.0.0-...-5bcdd56 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

HAM: Html As Modules

HAM makes modular HTML development possible. HAM provides a framework and compilier for developing static HTML web pages

HAM CONCEPTS

Layouts

A Layout defines the structure of a web page

<html lang="en">
<head>
     <meta charset="UTF-8">
     <title>HAM</title>
     <link type="ham/layout-css"/>
</head>
<body>

<div id="app-info"></div>
<div class="container">
     <div class="row">
          <embed type="ham/page"/>
     </div>
</div>
<embed type="ham/layout-js"/>
</body>
</html>
Pages

A Page must have a layout. A page gives a layout content

<div class="page"
     data-ham-page-config='{
     "layout": "../layouts/default.html",
     "css": ["../assets/app/css/index.css"],
     "js": ["../assets/app/js/index.js"]
     }'
>
  <embed type="ham/partial" src="../partials/header.html"/>
</div>
Partials

Partials are reusable html modules that can be included on a page or layout

<h1>Welcome to HAM</h1>
Final Result
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <title>HAM</title>
  <link rel="stylesheet" href="/assets/app/css/index.css?v=202102082042"/>
</head>
<body>
<div id="app-info"></div>
<div class="container">
  <div class="row">
    <div class="page">
      <h1>Welcome to HAM</h1>
    </div>
  </div>
</div>
<script src="../assets/app/js/index.js?v=202102082042"></script>
</body>
</html>
INSTALLING HAM

go install github.com/fobilow/ham/cmd/ham@latest

For specific version, replace @latest with version number

USING HAM
  • ham init [sitename]
  • ham build -w [working dir] -o [output directory]
  • ham version
  • ham help

Documentation

Index

Constants

View Source
const DefaultOutputDir = "./public"

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

func New

func New(workingDir, outputDir string) (*Compiler, error)

func (*Compiler) Compile

func (c *Compiler) Compile() error

func (*Compiler) Reset

func (c *Compiler) Reset()

type Embed

type Embed struct {
	Type string
	Src  string
}

type Layout

type Layout struct {
	Src    string   `json:"layout"`
	CSS    []string `json:"css,omitempty"`
	Js     []string `json:"js,omitempty"`
	JsMod  []string `json:"js-mod,omitempty"`
	Embeds []Embed
}

func ParseLayout

func ParseLayout(doc *html.Node) Layout

type Page

type Page struct {
	Layout *Layout
	Embeds []Embed
}

func ParsePage

func ParsePage(doc *html.Node) Page

type Site

type Site struct {
	// contains filtered or unexported fields
}

func NewSite

func NewSite() *Site

func (*Site) Build

func (h *Site) Build(workingDir, outputDir string) error

func (*Site) Help

func (h *Site) Help() string

func (*Site) NewProject

func (h *Site) NewProject(siteName, workingDir string) error

Directories

Path Synopsis
cmd
ham

Jump to

Keyboard shortcuts

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