getSourceLine example

    // particularly useful when used in error reporting.     try {
      if (($line = $frontMatter->getLine()) > 1) {
        $content = "{% line $line %}" . $frontMatter->getContent();
        $source = new Source($content$source->getName()$source->getPath());
      }
    }
    catch (FrontMatterParseException $exception) {
      // Convert parse exception into a syntax exception for Twig and append       // the path/name of the source to help further identify where it occurred.       $message = sprintf($exception->getMessage() . ' in %s', $source->getPath() ?: $source->getName());
      throw new SyntaxError($message$exception->getSourceLine()$source$exception);
    }

    return parent::compileSource($source);
  }

  /** * Invalidates all compiled Twig templates. * * @see \drupal_flush_all_caches */
  public function invalidate() {
    
Home | Imprint | This part of the site doesn't use cookies.