Coder Social home page Coder Social logo

fluent-html's People

Contributors

bjuppa avatar

Watchers

 avatar  avatar  avatar

Forkers

alphapipe

fluent-html's Issues

Optionally not closing elements

What if we could add withoutCloseTag($keep_open=true) that makes a FluentHtmlElement not render it's closing tag in branchToHtml()?
(it would also require an additional parameter to HtmlBuilder::buildHtmlElement() that keeps the tag open)

Then we could open up elements to allow a static open() call that works the same as create() (or the constructor) but keeping the tag open.

I guess we'd need to keep a (private static) stack of open elements in FluentHtmlElement and set the last non-closed element as parent to an empty (no element name) holder element and set that holder as parent on any new instances created when a tag is open.
(The holder would be needed to keep the possibility of adding content before and after the current element.)

(Can an abstract class have static variables? If not, that won't work... But I think they can, referenced in a method on the abstract class using self::$static_var - not static::$static_var)

Then there should be a static close() method that pops the last open element from the stack, and returns a close tag string.

This would of course not work in any situation where a child element is trying to change or add content to a non-closed parent element that has already been rendered. The change would be done, but not visible. But that situation should be pretty rare.

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.