Giter Club home page Giter Club logo

micro.js's Introduction

Micro.js logo

v1.4.5

Micro.js, simple and easy to use framework made by PDKnight.

#Documentation

####Try it yourself! ####Example of Micro.js website

Micro.js tester Commands

##Install

  • Download the latest minified version of micro.js file.
  • Include it in your HTML file and enable Micro.js for an element (for example body) with m-enable attribute:
<body m-enable="path/to/your/index">
    <script src="path/to/your/micro.min.js"></script>
</body>
  • That's it! Now you can edit your .mi file and watch the magic! :)

Note: you don't have to put .mi at the end of the m-enable attribute, so if we use index, Micro.js tries to find index.mi file.

##Features: ###Compatibility Works with every browser. ###Simple syntax Literally. Look at this example:

Hello, b [world]!

###Custom functions #####Micro.read(fn, text, [show_miliseconds]) Converts Micro.js text to HTML.

  • Arguments:
  • fn: Function where will be the result parsed.
  • text: Text to convert to HTML.
  • show_miliseconds (optional): If set to true, framework will output an array: [miliseconds, converted_text].

Example:

Micro.read(function(r) {
    console.log(r);
}, 'h1 [Hello, world!]', true); // Will print to the console: [1, "<h1>Hello, world!</h1>"]

#####Micro.render(text, element, [element2]) Renders the text.

  • Arguments:
  • text: Text to convert to HTML.
  • element: Element to write the result HTML.
  • element2 (optional): Element to write time it took Micro.js to process the text.

Example:

Micro.render('h1 [Hello, world!]', document.body); // Will render big header in body element.

#####Micro.getResponse(url, fn, err, bool) Makes an AJAX request.

  • Arguments:
  • url: A path to the file you want to get contents from.
  • fn: Function there the response text will be send to.
  • err: Error function which will be called when there was an error while getting file.
  • bool: true (asynchronous) or false (synchronous)

Example

Micro.getResponse('myFile.txt', function(response) {
    console.log('Succes!', response);
}, function(e) {
    console.log('AJAX failed :( Error message:', e);
}, true);

##Debugging In the case micro.js will print an error, find it in the table below:

Error Description Example Solution
There's an unwanted closing parenthesis in your .mi file. You have somewhere an extra ]. a [b]] a [b]
Unknown property: [property]. Micro.js doesn't know your property. @console_outputt: on @console_output: on
Wrong syntax. Use pattern -> property: value. You used wrong property pattern. a (b) [d] a (b:c) [d]
Unsupported property syntax: <syntax>. You didn't use an alphanumeric property. a (*:y) [d] a (x:y) [d]
Please import only .css or .js file(s). Your import file doesn't end with css or .js extension. @import x @import x.css
Unknown command statement: <statement> Your command statement is invalid. {echo} {echo: a}
File named <name> doesn't exist. The file used with get command doesn't exist. Check your file path.
Correct syntax: rand a b ... n There must be at least one argument. {rand a} {rand a b}
Correct syntax: def a b Invalid syntax. {def a} {def a b}
Only alphanumeric words (with optional hyphen) are supported. {def * b} {def a b}
Correct syntax: set-cookie name value. {set-cookie a} {set-cookie a b}
Correct syntax: repeat count [optional command]. {repeat *} {repeat 2 echo a}
Count must be an integer. {repeat *} {repeat 2}
Count must be an integer. {repeat *} {repeat 2}
You can't end a repeat without starting it. {end-repeat} {}
Condition must contain one of operators (==, !=, >, >=, <, <=). {if a} {if 1 < 2}
You can compare only integers with < operator. {if a > b} {if 1 < 2}
You can't end a condition without starting it. {end-if} {}
Unknown command: <command> {a b} {}
Unsupported element: <tagname> Your code contains style or script tag. style[]

If not, then keep these steps:

  1. Create a new post in issues section with code and version of Micro.js included.
  2. That's it!

micro.js's People

Contributors

patrik-herman avatar

Stargazers

 avatar  avatar BOTjr. 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.