- 97hcRAjsUzKg
- <time>1711476264</time><short>26/3/24</short><long>Tuesday, March 26, 2024 7:04:24 PM</long>
- unread
- 8 : KrISS aaaa : html
- tontof
- L'idée de Tom Butler pour la génération des pages PHP est vraiment originale. Son implémentation avec <a href="https://github.com/Level-2/Transphporm">Transphporm</a> montre une approche différente des autres projets plus classiques comme <a href="https://twig.symfony.com/">Twig</a>. À ma connaissance c'est vraiment le seul projet qui utilise cette idée et théoriquement c'est très élégant dans le monde de la programmation object.<br />
<br />
Pour mon approche plus impérative avec <a href="https://github.com/kriss/aaaa">KrISS aaaa</a>, j'ai imaginé l'utilisation d'un tableau associatif pour manipuler le code html à générer. Pour cela j'ai donc fait plusieurs fonctions pour transformer du code html en tableau associatif et vice versa.<br />
<br />
En pratique, ça donne : <code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php </span><span style="color: #007700">include(</span><span style="color: #DD0000">'src/helpers/html/html.php'</span><span style="color: #007700">);<br />
<br />
</span><span style="color: #0000BB">$string </span><span style="color: #007700">= </span><span style="color: #DD0000">'<br />
<!DOCTYPE html><br />
<html lang="en"><br />
<head><br />
<meta charset="utf-8"><br />
<title>Title</title><br />
</head><br />
<body><br />
body<br />
</body><br />
</html><br />
'</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$array </span><span style="color: #007700">= </span><span style="color: #0000BB">html_to_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">));<br />
</span><span style="color: #0000BB">$arraySimplified </span><span style="color: #007700">= </span><span style="color: #0000BB">array_html_simplify</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'head'</span><span style="color: #007700">][</span><span style="color: #DD0000">'title'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"New title"</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">] = [[</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"new body"</span><span style="color: #007700">]];<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">][] = [</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"add body"</span><span style="color: #007700">];<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">)); </span><span style="color: #0000BB">?></span><br />
</span><br />
</code><br />
<br />
Ce qui donne comme résultat :<br />
<code>string(110) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Title</title></head><body>body</body></html>"<br />
array(2) {<br />
'!DOCTYPE' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
[0] =><br />
string(4) "html"<br />
}<br />
}<br />
'html' =><br />
array(3) {<br />
'@' =><br />
array(1) {<br />
'lang' =><br />
string(2) "en"<br />
}<br />
'head' =><br />
array(2) {<br />
'meta' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
'charset' =><br />
string(5) "utf-8"<br />
}<br />
}<br />
'title' =><br />
string(9) "New title"<br />
}<br />
'body' =><br />
array(2) {<br />
[0] =><br />
array(1) {<br />
'p' =><br />
string(8) "new body"<br />
}<br />
[1] =><br />
array(1) {<br />
'p' =><br />
string(8) "add body"<br />
}<br />
}<br />
}<br />
}<br />
string(140) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>New title</title></head><body><p>new body</p><p>add body</p></body></html>"<br />
<br />
</code><br />
<br />
Une remarque importante, cela ne génère pas de code html avec des retours à la ligne et des indentations mais c'est un choix volontaire. Bien sûr cela peut poser problème avec les affichages inline-block qui ne réagissent pas exactement de la même façon s'il y a des espaces entre les balises ou non.<br />
<br />
Le but étant de rester minimaliste, ce comportement est donc voulu !<br />
It's not a bug it's a feature!
- https://tontof.net/index.php?2024/03/26/19/04/24-8-kriss-aaaa-html
- L'idée de Tom Butler pour la génération des pages PHP est vraiment originale. Son implémentation avec <a href="https://github.com/Level-2/Transphporm">Transphporm</a> montre une approche différente des autres projets plus classiques comme <a href="https://twig.symfony.com/">Twig</a>. À ma connaissance c'est vraiment le seul projet qui utilise cette idée et théoriquement c'est très élégant dans le monde de la programmation object.<br />
<br />
Pour mon approche plus impérative avec <a href="https://github.com/kriss/aaaa">KrISS aaaa</a>, j'ai imaginé l'utilisation d'un tableau associatif pour manipuler le code html à générer. Pour cela j'ai donc fait plusieurs fonctions pour transformer du code html en tableau associatif et vice versa.<br />
<br />
En pratique, ça donne : <code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php </span><span style="color: #007700">include(</span><span style="color: #DD0000">'src/helpers/html/html.php'</span><span style="color: #007700">);<br />
<br />
</span><span style="color: #0000BB">$string </span><span style="color: #007700">= </span><span style="color: #DD0000">'<br />
<!DOCTYPE html><br />
<html lang="en"><br />
<head><br />
<meta charset="utf-8"><br />
<title>Title</title><br />
</head><br />
<body><br />
body<br />
</body><br />
</html><br />
'</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$array </span><span style="color: #007700">= </span><span style="color: #0000BB">html_to_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">));<br />
</span><span style="color: #0000BB">$arraySimplified </span><span style="color: #007700">= </span><span style="color: #0000BB">array_html_simplify</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'head'</span><span style="color: #007700">][</span><span style="color: #DD0000">'title'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"New title"</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">] = [[</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"new body"</span><span style="color: #007700">]];<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">][] = [</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"add body"</span><span style="color: #007700">];<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">)); </span><span style="color: #0000BB">?></span><br />
</span><br />
</code><br />
<br />
Ce qui donne comme résultat :<br />
<code>string(110) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Title</title></head><body>body</body></html>"<br />
array(2) {<br />
'!DOCTYPE' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
[0] =><br />
string(4) "html"<br />
}<br />
}<br />
'html' =><br />
array(3) {<br />
'@' =><br />
array(1) {<br />
'lang' =><br />
string(2) "en"<br />
}<br />
'head' =><br />
array(2) {<br />
'meta' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
'charset' =><br />
string(5) "utf-8"<br />
}<br />
}<br />
'title' =><br />
string(9) "New title"<br />
}<br />
'body' =><br />
array(2) {<br />
[0] =><br />
array(1) {<br />
'p' =><br />
string(8) "new body"<br />
}<br />
[1] =><br />
array(1) {<br />
'p' =><br />
string(8) "add body"<br />
}<br />
}<br />
}<br />
}<br />
string(140) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>New title</title></head><body><p>new body</p><p>add body</p></body></html>"<br />
<br />
</code><br />
<br />
Une remarque importante, cela ne génère pas de code html avec des retours à la ligne et des indentations mais c'est un choix volontaire. Bien sûr cela peut poser problème avec les affichages inline-block qui ne réagissent pas exactement de la même façon s'il y a des espaces entre les balises ou non.<br />
<br />
Le but étant de rester minimaliste, ce comportement est donc voulu !<br />
It's not a bug it's a feature!
- <name>title</name><content>8 : KrISS aaaa : html</content><attributes> <name>link</name><content>https://tontof.net/index.php?2024/03/26/19/04/24-8-kriss-aaaa-html</content><attributes> <name>description</name><content>L'idée de Tom Butler pour la génération des pages PHP est vraiment originale. Son implémentation avec <a href="https://github.com/Level-2/Transphporm">Transphporm</a> montre une approche différente des autres projets plus classiques comme <a href="https://twig.symfony.com/">Twig</a>. À ma connaissance c'est vraiment le seul projet qui utilise cette idée et théoriquement c'est très élégant dans le monde de la programmation object.<br />
<br />
Pour mon approche plus impérative avec <a href="https://github.com/kriss/aaaa">KrISS aaaa</a>, j'ai imaginé l'utilisation d'un tableau associatif pour manipuler le code html à générer. Pour cela j'ai donc fait plusieurs fonctions pour transformer du code html en tableau associatif et vice versa.<br />
<br />
En pratique, ça donne : <code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php </span><span style="color: #007700">include(</span><span style="color: #DD0000">'src/helpers/html/html.php'</span><span style="color: #007700">);<br />
<br />
</span><span style="color: #0000BB">$string </span><span style="color: #007700">= </span><span style="color: #DD0000">'<br />
<!DOCTYPE html><br />
<html lang="en"><br />
<head><br />
<meta charset="utf-8"><br />
<title>Title</title><br />
</head><br />
<body><br />
body<br />
</body><br />
</html><br />
'</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$array </span><span style="color: #007700">= </span><span style="color: #0000BB">html_to_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">));<br />
</span><span style="color: #0000BB">$arraySimplified </span><span style="color: #007700">= </span><span style="color: #0000BB">array_html_simplify</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'head'</span><span style="color: #007700">][</span><span style="color: #DD0000">'title'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"New title"</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">] = [[</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"new body"</span><span style="color: #007700">]];<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">][] = [</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"add body"</span><span style="color: #007700">];<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">)); </span><span style="color: #0000BB">?></span><br />
</span><br />
</code><br />
<br />
Ce qui donne comme résultat :<br />
<code>string(110) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Title</title></head><body>body</body></html>"<br />
array(2) {<br />
'!DOCTYPE' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
[0] =><br />
string(4) "html"<br />
}<br />
}<br />
'html' =><br />
array(3) {<br />
'@' =><br />
array(1) {<br />
'lang' =><br />
string(2) "en"<br />
}<br />
'head' =><br />
array(2) {<br />
'meta' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
'charset' =><br />
string(5) "utf-8"<br />
}<br />
}<br />
'title' =><br />
string(9) "New title"<br />
}<br />
'body' =><br />
array(2) {<br />
[0] =><br />
array(1) {<br />
'p' =><br />
string(8) "new body"<br />
}<br />
[1] =><br />
array(1) {<br />
'p' =><br />
string(8) "add body"<br />
}<br />
}<br />
}<br />
}<br />
string(140) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>New title</title></head><body><p>new body</p><p>add body</p></body></html>"<br />
<br />
</code><br />
<br />
Une remarque importante, cela ne génère pas de code html avec des retours à la ligne et des indentations mais c'est un choix volontaire. Bien sûr cela peut poser problème avec les affichages inline-block qui ne réagissent pas exactement de la même façon s'il y a des espaces entre les balises ou non.<br />
<br />
Le but étant de rester minimaliste, ce comportement est donc voulu !<br />
It's not a bug it's a feature!</content><attributes> <name>dc:date</name><content>2024-03-26T19:04:24+01:00</content><attributes> <name>dc:language</name><content>fr</content><attributes> <name>dc:creator</name><content>tontof</content><attributes> <name>dc:subject</name><content>A simple and smart (or stupid) blog</content><attributes> <name>content:encoded</name><content>L'idée de Tom Butler pour la génération des pages PHP est vraiment originale. Son implémentation avec <a href="https://github.com/Level-2/Transphporm">Transphporm</a> montre une approche différente des autres projets plus classiques comme <a href="https://twig.symfony.com/">Twig</a>. À ma connaissance c'est vraiment le seul projet qui utilise cette idée et théoriquement c'est très élégant dans le monde de la programmation object.<br />
<br />
Pour mon approche plus impérative avec <a href="https://github.com/kriss/aaaa">KrISS aaaa</a>, j'ai imaginé l'utilisation d'un tableau associatif pour manipuler le code html à générer. Pour cela j'ai donc fait plusieurs fonctions pour transformer du code html en tableau associatif et vice versa.<br />
<br />
En pratique, ça donne : <code><span style="color: #000000"><br />
<span style="color: #0000BB"><?php </span><span style="color: #007700">include(</span><span style="color: #DD0000">'src/helpers/html/html.php'</span><span style="color: #007700">);<br />
<br />
</span><span style="color: #0000BB">$string </span><span style="color: #007700">= </span><span style="color: #DD0000">'<br />
<!DOCTYPE html><br />
<html lang="en"><br />
<head><br />
<meta charset="utf-8"><br />
<title>Title</title><br />
</head><br />
<body><br />
body<br />
</body><br />
</html><br />
'</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$array </span><span style="color: #007700">= </span><span style="color: #0000BB">html_to_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">));<br />
</span><span style="color: #0000BB">$arraySimplified </span><span style="color: #007700">= </span><span style="color: #0000BB">array_html_simplify</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'head'</span><span style="color: #007700">][</span><span style="color: #DD0000">'title'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"New title"</span><span style="color: #007700">;<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">] = [[</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"new body"</span><span style="color: #007700">]];<br />
</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">[</span><span style="color: #DD0000">'html'</span><span style="color: #007700">][</span><span style="color: #DD0000">'body'</span><span style="color: #007700">][] = [</span><span style="color: #DD0000">"p" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"add body"</span><span style="color: #007700">];<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">);<br />
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_to_html</span><span style="color: #007700">(</span><span style="color: #0000BB">$arraySimplified</span><span style="color: #007700">)); </span><span style="color: #0000BB">?></span><br />
</span><br />
</code><br />
<br />
Ce qui donne comme résultat :<br />
<code>string(110) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Title</title></head><body>body</body></html>"<br />
array(2) {<br />
'!DOCTYPE' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
[0] =><br />
string(4) "html"<br />
}<br />
}<br />
'html' =><br />
array(3) {<br />
'@' =><br />
array(1) {<br />
'lang' =><br />
string(2) "en"<br />
}<br />
'head' =><br />
array(2) {<br />
'meta' =><br />
array(1) {<br />
'@' =><br />
array(1) {<br />
'charset' =><br />
string(5) "utf-8"<br />
}<br />
}<br />
'title' =><br />
string(9) "New title"<br />
}<br />
'body' =><br />
array(2) {<br />
[0] =><br />
array(1) {<br />
'p' =><br />
string(8) "new body"<br />
}<br />
[1] =><br />
array(1) {<br />
'p' =><br />
string(8) "add body"<br />
}<br />
}<br />
}<br />
}<br />
string(140) "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>New title</title></head><body><p>new body</p><p>add body</p></body></html>"<br />
<br />
</code><br />
<br />
Une remarque importante, cela ne génère pas de code html avec des retours à la ligne et des indentations mais c'est un choix volontaire. Bien sûr cela peut poser problème avec les affichages inline-block qui ne réagissent pas exactement de la même façon s'il y a des espaces entre les balises ou non.<br />
<br />
Le but étant de rester minimaliste, ce comportement est donc voulu !<br />
It's not a bug it's a feature!</content><attributes>
- false