0.2.0-alpha • Published 9 years ago

xsalt v0.2.0-alpha

Weekly downloads
45
License
-
Repository
github
Last release
9 years ago

xsalt

WARNING This is highly experimental and has known, major security risks. For educational purposes only. Bug reports and pull requests welcome.

What a template could look like:

<html>
<head>
    <link rel="icon" href="data:;base64,iVBORw0KGgo=">
    <link rel="stylesheet" type="text/css" href="style.css">
    <script src="xsalt.js"></script>
    <script src="car.js"></script>
</head>
<body>

<ul xs-ctrl="CarsCtrl">
    <template>
        <li xs-each="cars" id="car_${_id}" xs-class="styles(${state})">
            <span>${state}</span>
            <span xs-class="smiles(${state})">${plate}</span>
            <span xs-if="${state === 'AK'}">
                The last frontier
            </span>
            <button xs-click="save(${_id})">Save</button>
            <button xs-click="delete(${_id})">Delete</button>
        </li>
    </template>
</ul>

</body>
</html>

What a controller might look like:

var Cars = xsalt.ctrl('CarsCtrl', ($ctrl) => {

    $ctrl.styles = function(data) {
        if ( data.state === 'UT' ) {
            return 'beehive cheddar';
        }

        else if( data.state === 'AK' ) {
            return 'tlf';
        }

        else {
            return '';
        }
    };

    $ctrl.smiles = function(data) {
        if ( data.state === 'MT' || data.state === 'AK' ) {
            return 'mountain';
        }

        else {
            return '';
        }
    };

    $ctrl.save = function(id) {
        console.log('saving: ', $ctrl.cars[id] );
    };

    $ctrl.cars = {
        1: { _id: 1, state: 'UT', plate: '234 ASD' },
        2: { _id: 2, state: 'MT', plate: '234 MDT' },
        3: { _id: 3, state: 'WA', plate: '234 WER' },
        4: { _id: 4, state: 'AK', plate: '999 TLF' }

    };

});

Cars.delete = function del(id) {
    delete Cars.cars[id];
};
0.2.0-alpha

9 years ago

0.1.0

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago