Skip to content

dmitrivereshchagin/sprout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sprout Build Status

Simple DOM generator inspired by Emmet. Dumb and fluent.

Install

% composer require dmitrivereshchagin/sprout

Usage

You can build your DOM from subtrees in the following way (you should avoid recursion though)

use Sprout\Node as Root;

$head = Root::create('head')
    ->meta('charset="utf-8"')->merge()
    ->up()
    ->title()->text('Title')
    ->root()
;

$body = Root::create('body')
    ->h1('id="header"')->text('Header')
    ->up()
    ->p()->text('Paragraph of text.')->times(2)
    ->root()
;

echo Root::create('html', 'lang="en"')
    ->insert($head, $body)
;

Or you can build entire tree using marked nodes

echo Root::create('html', 'lang="en"')->mark('h')
    // head subtree
    // ...
    ->to('h')
    // body subtree
    // ...
    ->root()
;

Testing

% composer test

About

🌱 Simple DOM generator inspired by Emmet

Topics

Resources

License

Stars

Watchers

Forks

Languages