Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Display contents using Drupal8 Render API

By editor , 12 January, 2016
Question

How to show  contents  using Drupal8 Render API ?

 

Render arrays

 

Minimum:
        return  array(
            '#markup' => 'Hello. This is my First Page',
        );

Add / Manage allowed tags:
$output = array();
$output[] = array(
    '#markup' => '<strong>This is allowed</strong> <em>This is filtered</em>',
    '#allowed_tags' => ['strong'],
;

 

By default allowed tags (Not tested, To verify)
<p> <a> <em> <strong> <b> <i> <u> <strike> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <table> <tbody> <tr> <td> <th> <h1> <h2> <h3> <h4> <h5> <h6> <blockquote> <hr> <span> <br> <font> <sup> <sub> <div>

 

Source : https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/group/theme_render/8

Tags

  • Drupal 8
  • Code
  • Theming
Render a Render array to HTML code.

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer