Code Monkey home page Code Monkey logo

cherry-js's Introduction

Cherry.js

What is this?

This is a small JS framework I'm coding for fun. It's definately nowhere near production ready (or good) but hopefully one day!

It works in a similar way to AngularJS at the moment with a few differences (and a LOT of exclusions.) If you want to find out how to use it, look at example/index.html for an idea and a demo

How to contribute

First install the dev tools:

npm install

then once you have finished run gulp scripts to compile an updated version found in cherry.min.js

Getting started

First, include cherry.min.js and then create an app:

var app = new Cherry()

Then attach a new controller to that app:

var controller = app.controller('myApp', function($scope) {
  $scope.greeting = 'Hello world!'
})

Create a div with data-cherry set to your controller name:

<div data-cherry="myApp">
  {{greeting}}
</div>

should display 'Hello world!'

Click Actions

//-- Controller
$scope.sayHello = function(world) { alert('Hello', world)}

//-- Template
<button data-click="sayHello" data-arguments="world">Say Hello</button>

Models / Two way binding

//-- Template
<span>Hello {{place}}</span>
<input data-model="place">

When the input is changed, the 'Hello {{phrase}}' template is magically updated

Lists

//-- Controller
$scope.people = ['Andy Hamilton', 'Bob']

//-- Template
<ul>
  <li data-repeat="person in people">{{person}}</li>
</ul>

//-- Controller
$scope.posts = [{title: 'Hello world!'}]

//-- Template
<div data-repeat="post in posts">
  <h1>{{post.title}}</h1>
</div>

Dependency Injection

Cherry uses dependency injection. To declare a new injector you can use:

app.registerDependency('myDependency', function() {
  
  alert('Hello world')

})

Then just include it in your controller parameters and use it!

app.controller('myApp', function($scope, myDependency) {
  myDependency() #=> alert: Hello world
})

cherry-js's People

Contributors

andyhmltn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.