0.1.5 • Published 5 years ago

npjs v0.1.5

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

NPjs - Simple Single App Page

Online Demo

install

npm install npjs

script

https://simple-singal-app-page.herokuapp.com/np.min.js
https://simple-singal-app-page.herokuapp.com/np.js

usage

<html>
  <body>
    <div id="app"></div>
    <script src="https://simple-singal-app-page.herokuapp.com/np.min.js"></script>
    <script>
    	NP.init('app');
    </script>
  </body>
</html>

router

//client
NP.routes = [
  {
    path : '/your-path',
    template : {
      title : 'Your title',
      html : `Your HTML code`
    }
  }
];
//server
app.get('/your-path',function(request,response){
	response.render('client_file');
});

render data

using {{your_data}} in HTML code -> NP.data.your_data

if

<h1 np-if="seen">Seen</h1>
<script>
  NP.data.if.seen = true;  //false to hide element
</script>

for loop

<ol>
 <li np-for="human">
  <p style="color:red">
    <np tag="text-for" data="name"></np>
  </p>
  <p style="color:yellow">
    - <np tag="text-for" data="sex"></np>
  </p>
 </li>
</ol>
<script>
  NP.data.for = {
     human : [
      { name : 'bob' , sex : 'male' },
      { name : 'alice' , sex : 'female' }
    ]
  };
</script>

init css

<np tag="style">
    <!--your style code -->
</np>

init JS

<np tag="script">
    <!--your JS code -->
</np>

Proxy data

NP.dataProxy.???  //change dataProxy -> change data and data rendered in HTML

Components

you may refer offline demo using webpack

clone

git clone https://github.com/zenlykoi/NPjs-Simple-Single-App-Page.git

Install NPM

npm install

start server

node index
-> demo in http://localhost:3000/component-index

build

webpack

watch

webpack --watch

advice

You may use coffeeScript syntax in VScode to code component(multiline string) !

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago