azeem/jstatic

crashes when I try to run 2.0.0

Closed this issue · 10 comments

When I had 0.1.1 of jstatic I had no problems running the task but now when I try to run the same task I get:

Loading "jstatic.js" tasks...ERROR
>> Error: Cannot find module 'toposort'

any idea what the problem could be?

Hi. I have made lot of incompatible changes with 2.0.0

You will have to update your node dependencies. Also please check the readme file about configuring grunt task.

If you send me your grunt file, I can help migrating.

I'm quite new on node so when you say update is it the same as deleting the node_modules folder and install it again?

my config that worked on 0.1.1:

    jstatic: {
        options: {
            extraContext: ["./markup/sitedata.json"],
            swig: {
                root: ["./markup/", "./markup/partials"]
            }
        },
        site: {
            files: [
                {
                    src: ['./markup/pages/**/*.html', '!./markup/pages/**/_*.html'],
                    dest: "./gen/"
                }
            ]
        }
    }

woops! sorry this was a package.json issue. Should be fixed now!
Your gruntfile also looks okay, should work since you have not overridden most of the defaults.
In 2.0.0 i have merged the preprocessors and formatters into something called generators. And instead of
multiple passes, it uses depends. Please take a look at the readme for advanced config.

Thanks

Thanks, now I only get

Warning: Cannot extend "layout.html" because current template has no filename. Use --force to continue.

my folder structure looks like:

markup
├───pages
|   └───category
│   └───index.html
└───partials
└───layout.html

and the pages/index.html view looks like:

{% extends 'layout.html' %}
{% block content %}
test
{% endblock %}

and with the layout.html file I got a block {% block content %}{% endblock %}

This is caused because of the swig 1.x.x pre release. I have pushed a fix for the error.

However, you would have to use relative paths for the extends tag, because the root config is not supported anymore by swig.

The following change to pages/index.html should make it work

{% extends '../layout.html' %}
{% block content %}
test
{% endblock %}

this is so sad, kinda felt like it worked just perfect and now its quite much work to just get everything to work again

{% for file in fileContexts|reverse %}

Doesn´t list anything anymore (but everything builds now)

The file contexts behavior has changed, jstatic now uses a named dependency scheme for such cases. Please check the common tasks section in the readme file to find out how to create collection summary pages.

Really sorry about the difficulties you are facing with the migration. I believe this new system is more elegant and easier to work with, hence all the backward incompatible changes. Hope you find it more flexible and useful. I would also like to remind that you can still install the older version of jstatic from NPM.

Will play around a bit more, Im having a hard time understanding everything, when I use the options to config the layout it generates all my files but the output is just the layout.html markup on all my files any ideas? or do I have to to extend layout on all the pages?

Im trying with:

{{body|e("html")}}

but still it gives me

<ul>

You can use extend tags for all your swig source files without using layout at all.
layout is basically just a simple shortcut that jstatic provides, to wrap your generated content inside a swig template. This is required because in some cases we maybe generating content from things like markdown files, and would still want to wrap them inside a swig template.

Essentially what happens is: if a layout is provided then, after the content is generated from your source file, the layout template is run. The generated content is passed in variable body to the layout template. So inside your layout file you can insert the actual body with {{ body|raw }} (raw filter is required since swig escapes variable contents by default)

you can refer https://github.com/azeem/azeem.github.com/tree/source for a full site done using jstatic.

Thanks for all the help, will continue and see if I can configure this to suit what I really want. Thanks for the time you spent on helping me.