Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to make the with out #16

Closed
harikt opened this issue May 15, 2014 · 1 comment
Closed

Way to make the with out #16

harikt opened this issue May 15, 2014 · 1 comment

Comments

@harikt
Copy link
Member

harikt commented May 15, 2014

Hi Paul,

I forget there is a way to call h(), j() etc without making use of

<?php 
use Aura\Html\Escaper as e; 
e::h('Hello World');
?>

like adding a functions.php file and having something like

<?php
use Aura\Html\Escaper; 
function h($raw) 
{
    return Escaper::h($raw);
}

And this can be autoloaded by composer.

And I would like to alter the getStatic() to make sure the Escaper object is there.

    public static function getStatic()
    {
        if (! static::$escaper) {
            $html = new HtmlEscaper($this->flags, $this->encoding);
            $attr = new AttrEscaper($html, $this->encoding);
            $css = new CssEscaper($this->encoding);
            $js = new JsEscaper($this->encoding);
            static::$escaper = new self($html, $attr, $css, $js);
        }
        return static::$escaper;
    }

This make calling as h("Hello World") I guess 👍 .

Not sure whether you like or not.

@pmjones
Copy link
Member

pmjones commented May 15, 2014

Hm. That looks like the functions are global, which is something I'd rather avoid. Bad enough to be using static methods.

@harikt harikt closed this as completed May 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants