2.1.16 • Published 6 years ago

axonjs v2.1.16

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

AxonJS

A super tiny VueJS-like framework

AxonJS

Introduction

This is highly experimental and WIP, do not use this in any production software

Axon is an very small(~4KB) JavaScript framework inspired by Vue.js. Instead of using the v- namespace for directives, it uses x-.

This framework is not supposed or able to be "the next big framework", this is just a hobby project of mine. Functionality and compatibility is much more limited than in Vue, due to the difference in complexity of the codebase. Most of the API is either the same or very similar as in Vue, however make sure to read the docs.

Core Differences to Vue

Advantages:

  • Smaller file
  • Faster parsing and render

Disadvantages:

  • No mustache ({{}}) expressions
  • Less built-in directives
  • No component support
  • Limited directive expressions (x-if="foo.bar>=getBar()" for example doesn't work, only x-if="isBiggerEqual(foo.bar) would)
  • Much more

Usage

Axon can be installed from npm:

npm install axonjs -S

Syntax

Constructor

To start with Axon, you need to create a new Axon App:

//Axon({el, data, methods})
const app = new Axon({
    el: document.querySelector("#myApp"), // Root element
    data: {
        name: "Lorem ipsum",
        bar: "bar",
        list: [1, 4, 2]
    },
    methods: {
        setBar(val) {
            this.bar = val;
        },
        logBar(){
            console.log(this.bar);
        }
    }
});
<div id="myApp">
    <div>
        <label>Name:</label>
        <input type="text" x-model="name">
    </div>
    <div>
        <label>Bar:</label>
        <input type="text" x-model="bar">
        <button class="btn btn-primary" x-on:click="setBar('bar')">Reset Bar</button>
    </div>
    <div x-if="name.length">
        <p>Hello <span x-text="name"></span>! The value of `bar` is <span x-text="bar"></span></p>
    </div>
</div>

Directives

  • x-model="#property#": binds the property to the node and attaches an event to update
  • x-bind:#attr#="#property#": binds the value of the expression as the given attribute
  • x-text="#property#": inserts expression content as text
  • x-html="#property#": inserts expression content as HTML
  • x-if="#property#": if the value evaluates to true, this node and child-nodes will render, else they will be ignored and hidden
  • x-on:#event#="method()": attaches the given method as event-handler for the given event
  • x-for="#variable# of #property#": loops over values in Array and creates elements with bound data for each
2.1.16

6 years ago

2.1.15

6 years ago

2.1.14

6 years ago

2.1.13

6 years ago

2.1.12

6 years ago

2.1.11

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.20.1

7 years ago

0.20.0

7 years ago

0.19.0

7 years ago

0.18.1

7 years ago

0.18.0

7 years ago