Sign in

An error occurred during rendering process:

  • This topic has 2 replies, 2 voices, and was last updated 8 months, 3 weeks ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5320
    publii-slpa

    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
    Tomasz Dziuda

    Hi,

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

    },

    instead of:

    }

    It is a simple syntax error 🙂

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #5336
    publii-slpa

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.