Skip to content

exponent-ts pseudo-ported to PHP so I don't have to write screwy PHP code

Notifications You must be signed in to change notification settings

RepComm/component-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

component

A pseudo-port of exponent-ts for PHP

Example usage

//include the lib
include_once("component.php");

function test_component_php () {
  //Create a container for our content
  $content = new Component();

  $content->make("div")->
  textContent("Hello World")->

  //Styling
  styleItem("position", "absolute")->
  styleItem("top", "25%")->
  styleItem("left", "25%")->
  styleItem("width", "50vw")->
  styleItem("height", "50vh")->
  styleItem("background-color", "black")->
  styleItem("color", "white");

  //Iterate from 0 to 9

  //Declaring variable outside of the loop should save us some performance
  $child = 0;

  for ($i=0; $i < 10; $i++) {
    //Create a line break
    $child = new Component();
    $child->make("br")->

    //attach to the content as a child
    mount($content);

    //Create text span
    $child = new Component();
    $child->make("span")->

    //set the text content to "span " + iteration number
    textContent("span " . sprintf("%d", $i) )->

    //attach to the content as a child
    mount($content);
  }

  //walk the hierarchy and echo the HTML generated
  writeComponent($content);
}

test_component_php();

About

exponent-ts pseudo-ported to PHP so I don't have to write screwy PHP code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages