2017 © Pedro Peláez
 

library sprout

Simple DOM generator inspired by Emmet

image

dmitrivereshchagin/sprout

Simple DOM generator inspired by Emmet

  • Sunday, February 12, 2017
  • by dmitrivereshchagin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Sprout Build Status

Simple DOM generator inspired by Emmet. Dumb and fluent., (*1)

Install

% composer require dmitrivereshchagin/sprout

Usage

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

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, (*3)

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

Testing

% composer test

The Versions

12/02 2017

dev-master

9999999-dev

Simple DOM generator inspired by Emmet

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

html emmet