anahkiasen / html-object Goto Github PK
View Code? Open in Web Editor NEWA set of classes to create and manipulate HTML objects abstractions
License: MIT License
A set of classes to create and manipulate HTML objects abstractions
License: MIT License
Zero is mistreated because of simple "not" condition here.
Please could we have a tag on this project?
Currently former can't be used in any project with minimum stability "stable" as it depends on this project which doesn't have a stable release.
I see that there is a isSelfClosing
property, but no way to alter it as it's protected. I cannot figure out from docs nor code how I would make the meta
tag self-close. Is there something I'm missing, or is this not possible in the code's current state?
Please can you tag another release.
Exactly copy Sizzle's CSS-compatible selector, for have possibility do this:
$element->sizzle('.foo'); // return all tags in any depth with class foo
$element->sizzle('[data-custom=something]'); // filter by attributes
// etc
Symfony CSS selector can be utilized for path parsing procedure.
It seems more developer- and standards-friendly to manipulate HTML nodes structures.
Hello @Anahkiasen,
If you plan to continue this project and enable support for PHP >= 8, and/or replace Travis (which free version is no longer available), note that I already setup GitHub Actions on my fork https://github.com/kylekatarnls/html-object and made the needed change to make it compatible with upper versions of PHPUnit. If you wish I propose a pull-request for it after #35 and #36 are merged, please ping me, I would gladly do it.
And thank you for the html-object ๐
Is it possible to add raw values to data attributes?
If I pass a JSON string to Former with Former::text('tags', 'Tags')->dataTags($tags);
, the data get's encoded
Maybe an extra parameter to specify raw output?
Would like this, but need to be able to make a table from an array. Is this in the roadmap? ... and if so, what is the time line ?
Consider the following snippet:
$formGroup = \HtmlObject\Element::div();
$formGroup->nest(\HtmlObject\Input::text('foo'));
echo htmlentities($formGroup);
What I expect to get printed is:
<div><input type="text" name="foo"></div>
But, what really gets printed is:
Input
get printed correctly, if I use it alone htmlentities(\HtmlObject\Input::text('foo'))
<input type="text" name="foo">
The closing tag comes to haunt only when nesting it inside another tag.
After looking through the code, I think the issue can be solved by modifying the code for close
function on the Tag
class, as follows:
foreach ($this->children as $childName => $child) {
if ($child->isOpened ) { // <-- change condition to if ($child->isOpened && !$child->isSelfClosing) {
$openedOn = $childName;
$element .= $child->close();
} elseif ($openedOn and $child->isAfter($openedOn)) {
$element .= $child;
}
}
The problem is, I am not sure whether this fix will cause any side effects. :(
Can I please request a new version which includes #21 fix. Have been running off a fork for quite some time.
The problem described at already proposed PR #17
When attributes such as 'checked' and 'disabled' are false in 1.4.1 they are included within the HTML.
1.4.0:
<input type="checkbox" value="1" name="role_15" id="role_15">
1.4.1:
<input type="checkbox" value="1" name="role_15" id="role_15" checked="" disabled="">
This means they are disabled when they shouldn't be.
I'd love an addStyle
that works similar to addClass
. I'm open to making a PR for it if you're interested.
From 1.4.2 to 1.4.4 the behavior of data_foo() changed.
1.4.2:
<input data_foo="true" />
1.4.4:
<input data_foo />
I saw that there were some changes about false/empty attributes, if it was intentional then disconsider this issue, otherwise it might be interesting to restore this behavior.
Thanks
Is that by design?
hyphenated('foo:bar') leaves string unchanged,
After using appendChild()
, Text element rendering attempt raises error, because $this->value
is not string.
// add two empty cells into row
$tr->nest('td', '');
$tr->nest('td', '');
// but there is only one
// because it uses empty string as child id o_O
print $tr; // <tr><td></td></tr>
It is easy predictable side-effect โ node string content used as node id will fail at second inserted child with same content.
Hey, lately I get this error a lot:
Could not scan for classes inside "/var/www/html/bootstrap/vendor/anahkiasen/html-object/tests" which does not appear to be a file nor a folder
It only seems to happen with your package, do you have any idea why this could happen? When I look in the dir, the test folder is missing. Any idea what could be causing this?
When I rm -rf vendor/anahkiasen
and composer update again, it loads this package again from cache, but works..
The self closing tags don't really work... I changed two lines of code and that seems to fix it:
Tag.php (#109)
$this->isOpened = !$this->isSelfClosing;
Tag.php (#118)
return '<'.$this->element.Helpers::parseAttributes($this->attributes) . ($this->isSelfClosing ? ' /' : ''). '>';
PS: Great library!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.