title: How to pass a custom function to a Laravel Blade template?
body: <p>I have a custom function and I want to pass it in a blade template. Here is the function:</p>
  
  <pre><code>function trim_characters( $text, $length = 45, $append = '&amp;hellip;' ) {
  
      $length = (int) $length;
      $text = trim( strip_tags( $text ) );
  
      if ( strlen( $text ) &gt; $length ) {
          $text = substr( $text, 0, $length + 1 );
          $words = preg_split( "/[\s]|&amp;nbsp;/", $text, -1, PREG_SPLIT_NO_EMPTY );
          preg_match( "/[\s]|&amp;nbsp;/", $text, $lastchar, 0, $length );
          if ( empty( $lastchar ) )
              array_pop( $words );
  
          $text = implode( ' ', $words ) . $append;
      }
  
      return $text;
  }
  </code></pre>
  
  <p>And the usage is like this:</p>
  
  <pre><code>$string = "A VERY VERY LONG TEXT";
  trim_characters( $string );
  </code></pre>
  
  <p>Is it possible to pass a custom function to the blade template? Thank you.</p>