瀏覽代碼

render & output methods

ever.zet 15 年之前
父節點
當前提交
71bf2b6a95

+ 21 - 2
src/Symfony/Components/Templating/Helper/JavascriptsHelper.php

@@ -51,11 +51,11 @@ class JavascriptsHelper extends Helper
   }
 
   /**
-   * Returns a string representation of this helper as HTML.
+   * Returns HTML representation of the links to JavaScripts.
    *
    * @return string The HTML representation of the JavaScripts
    */
-  public function __toString()
+  public function render()
   {
     $html = '';
     foreach ($this->javascripts as $path => $attributes)
@@ -72,6 +72,25 @@ class JavascriptsHelper extends Helper
     return $html;
   }
 
+  /**
+   * Outputs HTML representation of the links to JavaScripts.
+   * 
+   */
+  public function output()
+  {
+    echo $this->render();
+  }
+
+  /**
+   * Returns a string representation of this helper as HTML.
+   *
+   * @return string The HTML representation of the JavaScripts
+   */
+  public function __toString()
+  {
+    return $this->render();
+  }
+
   /**
    * Returns the canonical name of this helper.
    *

+ 21 - 2
src/Symfony/Components/Templating/Helper/StylesheetsHelper.php

@@ -51,11 +51,11 @@ class StylesheetsHelper extends Helper
   }
 
   /**
-   * Returns a string representation of this helper as HTML.
+   * Returns HTML representation of the links to stylesheets.
    *
    * @return string The HTML representation of the stylesheets
    */
-  public function __toString()
+  public function render()
   {
     $html = '';
     foreach ($this->stylesheets as $path => $attributes)
@@ -72,6 +72,25 @@ class StylesheetsHelper extends Helper
     return $html;
   }
 
+  /**
+   * Outputs HTML representation of the links to stylesheets.
+   * 
+   */
+  public function output()
+  {
+    echo $this->render();
+  }
+
+  /**
+   * Returns a string representation of this helper as HTML.
+   *
+   * @return string The HTML representation of the stylesheets
+   */
+  public function __toString()
+  {
+    return $this->render();
+  }
+
   /**
    * Returns the canonical name of this helper.
    *