kirby/kirby/component/js.php
/**
   * Builds the html script tag for the given javascript file
   * 
   * @param string $src
   * @param boolean async
   * @return string
   */
Builds the html script tag for the given javascript file

@param string $src
@param boolean async
@return string
Builds the html script tag for the given javascript file @param string $src @param boolean async @return string
public function tag($src, $async = false) {
    if(is_array($src)) {
      $js = array();
      foreach($src as $s) $js[] = $this->tag($s, $async);
      return implode(PHP_EOL, $js) . PHP_EOL;
    }
    if($src == '@auto') {
      $file = $this->kirby->site()->page()->template() . '.js';
      $root = $this->kirby->roots()->autojs() . DS . $file;
      $src  = $this->kirby->urls()->autojs() . '/' . $file;
      if(!file_exists($root)) return false;
    }
    return html::tag('script', '', array(
      'src'   => url($src),
      'async' => $async
    ));
  }
public function tag ( $ src , $ async = false ) { if ( is_array ( $ src ) ) { $ js = array ( ) ; foreach ( $ src as $ s ) $ js [ ] = $ this -> tag ( $ s , $ async ) ; return implode ( PHP_EOL , $ js ) . PHP_EOL ; } if ( $ src == '@auto' ) { $ file = $ this -> kirby -> site ( ) -> page ( ) -> template ( ) . '.js' ; $ root = $ this -> kirby -> roots ( ) -> autojs ( ) . DS . $ file ; $ src = $ this -> kirby -> urls ( ) -> autojs ( ) . '/' . $ file ; if ( ! file_exists ( $ root ) ) return false ; } return html :: tag ( 'script' , '' , array ( 'src' => url ( $ src ) , 'async' => $ async ) ) ; }
Builds the html script tag for the given javascript file
Builds the html script tag for the given javascript file
// auto template css files