GithubHelp home page GithubHelp logo

machy8 / macdom Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 1.99 MB

๐Ÿฉ The best, highly customizable HTML preprocessor with many amazing features https://machy8.github.io/Macdom/.

License: BSD 3-Clause "New" or "Revised" License

PHP 75.60% HTML 23.61% Dockerfile 0.79%
html-preprocessor templating minification simplification preprocessor

macdom's Introduction

Macdom

Build Status Coverage Status Packagist License Join the chat at https://gitter.im/Machy8/Macdom

  • For more information see WIKI (always up to date to the newest stable version)
  • Try it on CODEPEN (JavaScript version is always behind the php version so it may contain bugs and errors that have already been fixed in the PHP version)

Sample

Macdom

!5
html
    head
        utf-8
        viewport
        favicon includes/favicon.ico
        title Macdom example
    body
        h1 #title .titles .main-title Hello world
        nav
            @ a $http://www.[@].com $blank Link on -
            [google] .first-link Google
            [yahoo] Yahoo
            [github] Github	
        div #wrapper Some text <b>here</b>.
        https://www.code.jquery.com/jquery-1.12.0.min.js async

Result

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta content="width=device-width" name="viewport">
		<link rel="shortcut icon" href="includes/favicon.ico">
		<title>Macdom example</title>
	</head>
	<body>
		<h1 id="title" class="titles main-title">Hello world</h1>
		<nav>
			<a target="blank" href="http://www.google.com" class="first-link">Link on - Google</a>
			<a target="blank" href="http://www.yahoo.com">Link on - Yahoo</a>
			<a target="blank" href="http://www.github.com">Link on - Github</a>
		</nav>
		<div id="wrapper">
			Some text <b>here</b>.
		</div>
		<script async="" type="text/javascript" src="https://www.code.jquery.com/jquery-1.12.0.min.js"></script>
	</body>
</html>

Requirements

  • PHP 7.0+
  • If you use Nette Framework - v2.3+

Installation

1 - Download the Macdom using composer:

 composer require machy8/macdom

2 - Usage:

Typical:

$macdom = new Macdom\Engine;
$compiled = $macdom->compile($content);

Nette framework:

use Macdom\Bridges\Latte\FileLoader;
use Macdom\Engine;

/**
 * @var Engine
 */
private $macdom;

/**
 * @var FileLoader
 */
private $fileLoader;


public function __construct(Engine $macdom, FileLoader $fileLoader) {
	$this->macdom = $macdom;
	$this->fileLoader = $fileLoader;
}


protected function createTemplate()
{
	$template = parent::createTemplate();
	$this->fileLoader->setMacdom($this->macdom);
	$template->getLatte()->setLoader($this->fileLoader);
	return $template;
}

And add a config neon file with the following content (or try Composer synchronizer. It will do it for you automatically).

extensions:
    macdom: Macdom\Bridges\Nette\MacdomExtension
  
macdom:
    debugger: TRUE

macdom's People

Contributors

gitter-badger avatar machy8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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