Build Status Coverage Status Packagist License Join the chat at

  • 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)



        favicon includes/favicon.ico
        title Macdom example
        h1 #title .titles .main-title Hello world
            @ a $http://www.[@].com $blank Link on -
            [google] .first-link Google
            [yahoo] Yahoo
            [github] Github	
        div #wrapper Some text <b>here</b>. async


<!DOCTYPE html>
		<meta charset="utf-8">
		<meta content="width=device-width" name="viewport">
		<link rel="shortcut icon" href="includes/favicon.ico">
		<title>Macdom example</title>
		<h1 id="title" class="titles main-title">Hello world</h1>
			<a target="blank" href="" class="first-link">Link on - Google</a>
			<a target="blank" href="">Link on - Yahoo</a>
			<a target="blank" href="">Link on - Github</a>
		<div id="wrapper">
			Some text <b>here</b>.
		<script async="" type="text/javascript" src=""></script>


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


1 - Download the Macdom using composer:

 composer require machy8/macdom

2 - Usage:


$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();
	return $template;

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

    macdom: Macdom\Bridges\Nette\MacdomExtension
    debugger: TRUE
  • v3.0.0 3.0.0

    • Completely redesigned version
    • See docs folder for changes
    • Requires PHP >= 7.0
    • If you use Nette framework >= 2.3
    • This version is incompatible with previous versions
  • v2.2.0 2.2.0

    • Fixes
      • macro selector is now replaced correctly
      • empty string in replicator is ignored
      • macros are detected properly in the replicator
    • New
      • string can be cleaned from both sides or only from left
      • is possible to add blank line on the end of the file
    • Other
      • Improved coding style
      • Renamed variables Elements, Macros, Setup, Replicator - now they start by lowercase letter
  • v2.1.0 2.1.0

    New Features

    • Script or css tag can by added through shortcut => script.js and style.css
    • New core macros - index-follow, no-index-follow
    • Added SKIP and SKIP-CONTENT selectors for skipping content
    • Is possible to add quick attributes via addQkAttributes()
    • Improved code connection in the replicator - by adding ‘|’ you can preserve the trailing space


    • Setup - code indentation options are now ‘spaces’, ‘tabs’, ‘combined’ instead of 1-3
    • Removed n:href support
    • Improved viewport Macro
    • Improved output code style


    • PHP >= 5.4.0
    • If you use Nette >= 2.3.0
  • v2.0.0 2.0.0

    • Changed directory structure
    • Modified setup
    • Added new options for setup
    • Added new tests
    • Various bugs fixed
    • Added selector for data-attribute
    • Better support for clean php
    • Better support for no-compile areas
    • Improved work with text
  • v1.3.0 1.3.0

    • Now is possible to use Macdom without Nette Framework
    • Added method for code compression
    • Various bugs fixed
    • Visual tests replaced by Nette tester tests
    • Improved coding style
    • Improved code annotations
  • v1.2 1.2

    • Added compileContent method.
    • Now is possible to compile selected content or a whole template even if you are not using Nette Framework.
  • v1.1 1.1



    • Macdom was separated on single components.
    • All classes has its own file.
    • Elements, elements settings and boolean attributes are now separated.
    • Is possible to choose which indent method you want to use.
    • Added methods for customization before compilation (is possible to add elements, macros, select indent method...).
    • Short selectors for classes are now synchronized with html class attributes.
    • Short id selector is now synchronized with html id selector.
    • Improved text connectors - text is now connected with a space according to conditions.

    Fixed issues

    • Detection of no compile area - now is detected even the close tag of no compile area
    • Adding close tags before html comments, text and content from no compile area.

    For more information visi WIKI

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette