How to link assets from Sage 9 controller class

sage9

#1

i try this, but asset_path is not valid
is there some elegant way without using ugly wordpress core functions?

class Single extends Controller
{
  /**
   * Return next post link
   *
   * @return string
   */
  public static function nextPostLink()
  {
    $arrow = asset_path('images/arrow.svg');
    $img = "<img class='arrow--left' src='$arrow'>";

    return next_post_link('%link', $img);
  }
}

#2

You’re forgetting the namespace.

\App\asset_path()


#3

Cool, that worked. It’s hard to find that in the docs, though…


#4

Btw, I love what you’re doing with Sage, Bedrock and Trellis
Recently found out how easily you can flip logic from views to controller - that’s awesome
Great job guys at Roots!


#5

Thanks! Was looking for this.