Brick : append a string triggers helpers

Hello fellow kirby lovers.

I just find out about something while using bricks.

So i’m using brick::append() to inject a string into a <b>element. Like so :

$b = brick('b')->append('Twitter');

Wich, i thought, was supposed to return :

<b>Twitter</b>.

However, this actually trigger the twitter() helper, trying to build a twitter link. (And throw a whoops E_Warning because the twitter helper is missing arguments, well, it does cause i didn’t wanted to use it)

Althrough, the use of append() for this isn’t the best method compared to brick::text(), which i use to solve my case, but i was wondering if this is a normal behavior l and i just missunderstood something about append() and PHP, or if this an actual issue ?

Thanks for reading :slight_smile: and wishe you best.
W.

Well, in this case it is a weird coincidence, because the append() method checks if the parameter passed to it is a callable, and if so, tries to call the function:

  public function append($html) {
    if(is_callable($html)) $html = $html();
    $this->html = $this->html . $html;
    return $this;
  }

So, yes, that is expected unexpected behavior :wink: The parameter you pass to append should rather be some HTML instead of plain text.

Hello Texnixe.

Thank you for the anwser and the details about append()!!
I’ll trully be more carefull to what i’ll be passing to it from now, and try to clearly differentiate it from text(). :grin: