static-dev / spike

A modern static build tool, powered by webpack
http://spike.js.org
Other
470 stars 29 forks source link

__runtime.escape(var) instead of parsed markdown #67

Closed colsen1991 closed 7 years ago

colsen1991 commented 7 years ago

Given locals = { foo: '**bar**' } in app.js and a simple view with

p {{foo}}
p(md) {{foo}}

I am greeted with

**bar**
__runtime.escape(foo)

in my browser.

I came across this issue when playing around with contentful (https://github.com/colsen1991/christerolsen-no/tree/spike), but managed to replicate the issue with a brand new project fresh from spike new

I've tried looking up help, but to no avail. The only post/issue I could find was https://github.com/static-dev/spike-core/issues/179 and the only difference seen here and on https://github.com/static-dev/spike-contentful from my config seems to be that reshape is passed as a function

reshape: (ctx) => {
  return htmlStandards({
     locals
  })
}

instead of reshape: htmlStandards({ locals }). But switching to a function gives me an error from webpack:

/home/colsen91/.nvm/versions/node/v8.1.2/lib/node_modules/spike/node_modules/webpack/lib/webpack.js:19
        throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
        ^

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[2].use should be one of these:
   non-empty string | function | object { loader?, options?, query? } | function | [non-empty string | function | object { loader?, options?, query? }]
   Details:
    * configuration.module.rules[2].use should be a string.
    * configuration.module.rules[2].use should be an instance of function.
    * configuration.module.rules[2].use should be an object.
    * configuration.module.rules[2].use should be one of these:
      non-empty string | function | object { loader?, options?, query? }
    * configuration.module.rules[2].use should be an instance of function.
    * configuration.module.rules[2].use[1] should be a string.
    * configuration.module.rules[2].use[1] should be an instance of function.
    * configuration.module.rules[2].use[1].options should be an object.
    * configuration.module.rules[2].use[1].options should be a string.
    * configuration.module.rules[2].use[1].options should be one of these:
      object | string
    * configuration.module.rules[2].use[1] should be one of these:
      non-empty string | function | object { loader?, options?, query? }
    at webpack (/home/colsen91/.nvm/versions/node/v8.1.2/lib/node_modules/spike/node_modules/webpack/lib/webpack.js:19:9)
    at Spike.watch (/home/colsen91/.nvm/versions/node/v8.1.2/lib/node_modules/spike/node_modules/spike-core/lib/index.js:56:21)
    at process.nextTick (/home/colsen91/.nvm/versions/node/v8.1.2/lib/node_modules/spike/lib/watch.js:3:34)
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)
    at Function.Module.runMain (module.js:607:11)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

This is both with webpack version "webpack": "^2.6.1".

Any thoughts?

Cheers!

jescalan commented 7 years ago

Hey @colsen1991 - this is a common issue and we have had a section covering this in the FAQs for a while, here it is!

https://spike.readme.io/docs/faqs#section-markdown-processing-locals

This is almost certainly our fault for not making it easy enough to find for you though. When you were searching for a solution, what was your process? It looks like you did an issue search, was there anywhere else you looked? Perhaps we can add cues to this page wherever you were looking to make it easier for people in the future.

I also have to recommend our community chat. We have had many people pop into the community chat to ask this question, and someone is pretty much always there to answer it right away. Either way, I'm really sorry that this hung you up for so long, and thank you for the thoroughly detailed issue!

colsen1991 commented 7 years ago

Thank you so much the quick reply. If only I'd sought help sooner rather than banging my head against the wall...

Mostly Google and, manual searches through your GitHub issues was my main way of attacking the problem. As well as dumbing down my project to hell and back. I guess I'm still pretty new to the OS community and need to learn to but problems aside and ask for help instead of trying to fix things myself, haha.

Thanks again. I'll drop by the chat next time :)

jescalan commented 7 years ago

Of course, happy to help, and sorry the head banging happened! Documentation is hard, but we're always trying to make it better. Something I've found in general working as an developer is that once I get to the point where I'm "spinning my wheels", asking for help is much better than keeping them spinning hah.

Either way, always here to support and make sure that your project turns out amazing ✨

colsen1991 commented 7 years ago

Hehe, yeah. Used to having a team of senior devs around, so asking for help isn't new. Just the asking on the internet part :)

Looking forward to working with Spike though! Keep it up :+1:

jescalan commented 7 years ago

Makes a lot of sense. We're here and got your back though if you need it 👬