Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mvc-lite

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvc-lite

Lite MVC Library using pure EcmaScript5

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

What is this repository for?

Pure Ecmascript 5 library for writing updatable components and use them in your HTML code, using a personal interpretation of the 'MVC' coding pattern.

How do I get set up?

All you need for this to work is to get one of the final builds ('mvc-lite.js' / 'mvc-lite.min.js') on your webpage.

Basic usage:

The HTML index file:

index.html

<!DOCTYPE html>
<html>
<head>
    <title>My Web App</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Compiled library code -->
    <script src="./dist/mvc-lite.js"></script>
    
    <!-- Compiled app code (controllers/injectables/models..) -->
    <script src="./dist/app.js"></script>

    <link rel="stylesheet" href="./main.css">
</head>
<body>
    <div controller="app"></div>

    <!-- main.js -->
    <script src="main.js"></script>
</body>
</html>

A simple controller will look like this:

app.js:

(function(global) {
	global.App.Controller('app', './', function($scope, _update) {
		$scope.title = "Hello World!";
	});	
})(Function('return this')());
  • 'app' - The name you will use to refer to that controller in the HTML.
  • './' - The relative path for the HTML file (must be named like the controller!).
  • 'function($scope, _update)' - A function that will be used to construct component instances.

app.html:

<div class="app-container">
	<h1 bind-value="title"></h1>
</div>
  • 'bind-value' - One of the builtin injectables which will inject the value of "title" from the $scope to the element's HTML.

Eventually, we will need to tell the framework to bootstrap the app with a specific controller:

main.js

(function(global) {

    global.App.Bootstrap('app');

})(Function('return this')());

FAQs

Package last updated on 28 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc