dcr_renderer
The DCR Renderer module provides a Twig extension and Single Directory Component (SDC) for fetching and rendering content from Drupal Content Repository URLs or local file paths. It has multiple processing options for proxying urls and assets.
It works hand in hand with the Drupal Content Repository module which makes URLs available for Drupal Entity which can be used to embed the entity in a Single Directory Component (SDC). The Drupal Content Repository it draws from can be on a remote Drupal server or on the same server.
Features
- Twig Extension: dcr_get_contents() function for fetching and processing remote/local content
- SDC Component: dcr-render component for embedding content with fallback options
- Multiple Processing Types: Raw, proxied, hardened, and full processing options
- Asset Extraction: Automatically handles CSS and JavaScript from fetched content
- Security Controls: Domain restrictions, file extension filtering, and content sanitization
- Caching: Configurable caching for improved performance
- Error Handling: Graceful fallbacks when content cannot be fetched
Post-Installation
You install the module and you can then use its built in SDC Component
DCR Renderer in Drupal Canvas or a twig template in order to see it.
Usage
In Drupal Canvas
- Click Edit if you are not in the Canvas Editor
- Click the + Look in the left column under DCR Renderer.
- Drag the DCR Renderer component onto your page.
- In the Properties editor on the right.
- Set the Content URL to the Drupal Content Repository URL or other URL.
- Set the Processing Type property if there are issues like broken links or invisible images.
- You should see the referenced content in the Drupal Canvas.
In a Twig Template
{# Basic usage - fetches and processes with default 'hardened' mode #} {{ dcr_get_contents('https://example.com/repository/node/123') }} {# With specific processing type #} {{ dcr_get_contents('https://example.com/repository/node/123', 'proxied') }} {# Local file #} {{ dcr_get_contents('public://dcr-content/page.html', 'hardened') }}
Recommended modules/libraries
The Drupal Content Repository module makes any Drupal Entity available with a URL or path and able to be embedded in a Single Directory Component (SDC). The Drupal Content Repository it draws from can be on a remote Drupal server or on the same server.
Related projects
The Static Content Type module makes static, React, Angular or Vue content embeddable in Single Directory Components (SDC) or Paragraphs, Nodes or Blocks. While the DCR Renderer is for Live Content From Drupal or elsewhere.