CSML

CSML is a little class (PHP5 only) that generates HTML tags from CSS-like selectors.

download-button

Why? Because I hate having HTML mixed up with PHP on my templates. I particularly hate how popular wordpress themes and plugins are coded where is dificult to follow conditional statements and loops starts or ends, because they are all scrambled with HTML tags.

With CSML, you can generate necessary HTML tags using CSS selectors inside your PHP code-blocks without escaping or concatenating long strings. If you already know some CSS, this syntax should be very easy to understand. 

The class has two main methods: csml::tag() generates a tag from a selector and csml::entag() wraps a string into a pair of selectors.

Here's an example:

Included with the class, there are to utility functions: t() and en() wich print the results from csml::tag() and csml::entag() respectively. This makes code even easier to write.

There's more documentation and samples on the project's README

download-button

Posted 2 months ago

2 comments

Dec 20, 2009
elcrayon said...
Justamente estaba pensando en el revoltijo "html/php" que suelen ser algunos templates, y a veces el codigo propio termina siendo un spagetti similar, creo que esta clase me va a venir de perlas para un proyecto con CodeIgniter que traigo entre manos.

Solo un detalle, los links del post apuntan a "github.com/sosa/XXX" y pues en ese repositorio no hay nada, trate de usar "github.com/sosKa/" y si estaban ahi, fuera de eso, excelente post y libreria, esperemos que se haga de una comunidad pronto, incluso podria integrarse perfecto en algunos frameworks.

Un saludo, buen trabajo.

Dec 21, 2009
Armando Sosa said...
@elcrayon: gracias por el comentario. Ya arreglé los links, si lo usas me dices :P

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     twitter