Git Product home page Git Product logo

magichtml's Introduction

MagicHTML

This is yet under development, so it will probably have some bugs. But it's a lot of fun already!

Some live preview

What it does?

MagicHTML is a php class for html handling.

You can set metas, title and w/e. The idea is you have an OO html.

Example of use:

require_once("MagicHTML.php");
$html = new MagicHTML;
$html->add_css_linked("preview.css");
$content = file_get_contents("elquery-test.html");
$html->set_content($content);
echo $html->create();

Ok, but why?

Check the fun part

CSS

It's boring and bad for us to write all our project css into one big file. But it's usual worse for the server to handle multiples requests of tiny little css.

MagicHTML fills this gap. It let you to write your modular css without causing troubles for your server.

How?

Before MagicHTML displays your page it checks the css's added to the page, and checks for a cache file that includes that expecific combination of css's.

If it doesn't find the cache file, it will make one. It will run file by file and minify it. After, it will generate one big file with the content of the small css's you like to read.

It compares the creation date of the cache file with the modification date of each file, so it will re-interprete the css after you update it

The fun part.

Because we already interprete files from time to time, to minify them, we can add custom functions to css.

I'm talking about using all the Less syntax, without using a javascript library and with it saving client resources.

I'm talking about using condicionals like:

if $browser == 'IE' and $version <= 8:
#example {width: 400px;}
elif: $browser == 'IE' and $version > 8:
#example {width: 300px;}
else:
#example {width: 600px;}
end

And inspired by this post element querys like:

#teste@eq(min width 380){background: blue; border:3px solid black;} #teste@eq(min width 380) p{font-size:16px;}

You can check css/preview.css so you can see the syntax we are working

Javascript

It, by default, positionate javascripts at the bottom of the page, so you can economize client resources.

Puts all inline javascript into one single block

Modularity

Originally i did this to use in a framework that i'm developing. It's incredbly easy to make it support templates and childrens, what i need, since i'm using mvc design pattern.

Even if you don't want to make it support templates in a OO way, you can always do something like this:

require_once("MagicHTML.php");
$html = new MagicHTML;
$html->add_css_linked("preview.css");
$header = file_get_contents("header.html");
$content = file_get_contents("content.html");
$footer = file_get_contents("footer.html");
$content = $header.$content.$footer
$html->set_content($content);
echo $html->create();

magichtml's People

Contributors

gabrielfelipec avatar gabriel-felipe avatar

Stargazers

Ribamar FS avatar Chris Rault avatar

Watchers

James Cloos avatar  avatar

Forkers

diysoho

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.