1.1.2 • Published 3 years ago

gpp-templator v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

gpp-templator - templator with TypeScript

Build Status

gpp-templator is a TypeScript library for building user interfaces.

  • Declarative: gpp makes it painless to create interactive UIs. Design simple views for each state in your application, and gpp will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.

Install

node 14.x

$ npm i gpp-templator

Usage

You can quick start here

For ease of use, use gpp-loader for webpack. Below is a quick example how to use gpp-templator:

// file: index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Quick example</title>
</head>
<body>
  <div class='app'></div>
</body>
</html>
// file: ./Page/Page.gpp.ts

import { Component } from 'gpp-templator'
import { Button } from '/home/project/src/components/Button/index.ts'

export class Page extends Component {

onClick = (e:Event) => {
  e.preventDefault()
  alert('On batton click!')
}

components() {
  return {
    Button
  }
}

state = {
  onClick: this.onClick
}

template() {
    return (
      `<div className='page'>
          <h1>Quick example</h1>
          <Button
            text='Button'
            id='button'
            onClick={{state.onClick}}
          ></Button>
        </div>
      </div>`
    )
  }
}
// file: ./Button/Button.gpp.ts

import { Component } from 'gpp-templator'

export class Button extends Component {

template() {
    return (
      `<button 
        className={{props.test}}
        id={{props.id}}
        onClick={{props.onClick}}
      ></>`
    )
  }
}
// file: index.ts

import { renderApp } from 'gpp-templator'
import { Page } from './Page'

renderApp(Page)
1.1.2

3 years ago

1.1.1

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago