Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

An error occurred during rendering process:

  • #5320
    Avatar photo[anonymous]

    Good people.

    I am creating my first theme. I have not yet created a website yet. I am learning as I go. I do intent to use Publii for several sites, but want to have my own themes using CoffeeCup Site Designer.

    I created a theme by obliterating the technews theme and get the following error when rendering “Preview your changes”

    Rendering process failed
    An error occurred during rendering process:

    Unexpected identifier

    I did try to create a custom helper, isEven, and put it in helpers.js. Here is the code.

    /*
     * Custom theme helpers for Handlebars.js
     */
    
    let themeHelpers = {
        getTagColor: function(tag, tagsConfig = '') {
            if(tagsConfig.trim() === '') {
                return 'u-tag--1';
            }
    
            tagsConfig = tagsConfig.split(',');
    
            if(tagsConfig.length) {
                tagsConfig = tagsConfig.map(item => item.split('='));
    
                for(let tagConfig of tagsConfig) {
                    if(tagConfig.length !== 2) {
                        continue;
                    }
    
                    if(tagConfig[0].trim() === tag) {
                        return 'u-tag--' + tagConfig[1];
                    }
                }
            } else {
                return 'u-tag--1';
            }
    
            return 'u-tag--1';
        }
    
        isEven: function(value, options) {
            if (value % 2 == 0) {
          return true;
      } else {
                return false;
            }
        }
    };
    
    module.exports = themeHelpers;

    Here is how I am using it in Handlebars (index.hbs).

    {{#each posts}}
        {{#isEven @index}}
        
    <h3 class="article-heading">{{title}}</h3> <p class="paragraph body-copy">{{{text}}}</p>
    <picture> Placeholder Picture </picture>
    {{else}}
    <picture> Placeholder Picture </picture>
    <h3 class="article-heading">{{title}}</h3> <p class="paragraph body-copy">{{{text}}}</p>
    {{/isEven}} {{#if @last}} {{else}}
    <hr>
    {{/if}} {{/each}}

    All the rest of the modifications to the theme come directly from your website — so this is only the tricky part.

    #5333
    Avatar photo[anonymous]

    Hi,

    In line 30. of your helpers.js you should use:

    },

    instead of:

    }

    It is a simple syntax error 🙂

    #5336
    Avatar photo[anonymous]

    Cheers mate!

    I went around and around on this, you know how it is, the issue is right in front of you and you cannot see it.

    Thanks again!!