Showing posts with label replace value in twig. Show all posts
Showing posts with label replace value in twig. Show all posts

Monday 12 August 2019

How to replace function use in Twig template?

It's a simple way to use "Replace" function in twig file just go through simple method:

Syntax with example:                   

{#
*** replace '-' with '$' sign in vidyard ID ***
#}

{% set twig_content_variable = node.field_resources_vidyard_id.value %}    //field_resources_vidyard_id is are vidyard id field
{% set replace_value_var = '-' %}
{% set replace_with_value_var = '$' %}
{% if twig_content_variable %}
{% set vidyard_function_id = twig_content_variable|replace({ '-': '$' }) %}
{% endif %}







Note: How to replace function use in Twig template?

Tuesday 4 September 2018

Replace any string or value in twig template variable.

If we want to Replace the value in twig template then we have an example and syntax, please have a look..
{#
    ****  replace '-' with '$' sign in vidyard ID ****  
#}

{% set twig_content_variable  = node.field_resources_vidyard_id.value  %}   // here we are applying on field_resources_vidyard_id field..
{% set replace_value_var      = '-' %}
{% set replace_with_value_var = '$' %}
{%if twig_content_variable %}
   {% set vidyard_function_id = twig_content_variable|replace({ '-': '$' }) %}
{% endif %}


Note: If have any suggestions or issue regarding 'Replace any string or value in twig template variable.' then you can ask by comments. 

How to resolve max execution time error in drupal ?

When you found error regarding 'max_execution_time' exceed, then you can follow steps for resolve this error: Steps:   You can put t...