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. 

3 comments:

  1. Nice article. Its very useful for me

    ReplyDelete
  2. Can you Please create a article for paragraph fields, how to call paragraph fields on twig template.

    ReplyDelete
    Replies
    1. Hi,
      We have an article for paragraph fields render on node twig file, please have a look..
      https://drupalwebsolutions.blogspot.com/2018/09/paragraph-fields-render-in-drupal-8.html

      Delete

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...