renderInTemplate() forgives to escape # for nested template

2 posts, 0 answers
  1. Paolo
    Paolo avatar
    18 posts
    Member since:
    Mar 2017

    Posted 19 Dec 2017 Link to this post


    I am using renderInTemplate() to nest some widget, in particular, grid inside a window, I discovered the following method is missing to replace # in case the widget is nested inside another and the inner one contains in its definition a template string, so I suggest to patch width in a similar way ( more testing by your side is needed but It permitted to remova a Uncaught Error: Invalid template:' error in my application )


         public function renderInTemplate() {
            $this->isClientTemplate = true;
            $output = $this->render();
            $this->isClientTemplate = false;
            $output = str_replace('</script>', '<\\/script>', $output);

            // ADD THIS LINE to Replace also hash to prevent Uncaught Error: Invalid template:'

            return str_replace('#', '\\#', $output);



  2. Dimitar
    Dimitar avatar
    294 posts

    Posted 21 Dec 2017 Link to this post

    Hello Paolo,

    Thank you for the feedback provided.

    In order to properly handle the # character in a binding expression of a nested template, this character must be escaped with via \\# and this behavior is implemented by design. In this way the character is ignored by the outer template, but is handled correctly by the inner template. This is documented in the official Templates Documentation:

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.

Back to Top