Pretty print Jade in watch

52 views
Skip to first unread message

cha...@gmail.com

unread,
Oct 13, 2014, 5:33:05 AM10/13/14
to mimo...@googlegroups.com
Hi

this might be an easy one but I could figure it out...
I would like the html from "mimosa watch -s" to be "pretty". I tried "jade": {"pretty":true} and "jade-static": {"pretty": true} but non of it worked.

Any ideas where I can set this option?

Cheers
Michael

GMail

unread,
Oct 13, 2014, 7:23:06 AM10/13/14
to mimo...@googlegroups.com
This the module you are using?

https://github.com/dbashford/mimosa-client-jade-static#default-config

Sent from my iPhone
> --
> You received this message because you are subscribed to the Google Groups "mimosajs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mimosajs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Michael Keller

unread,
Oct 13, 2014, 7:26:27 AM10/13/14
to mimo...@googlegroups.com
Yes, but only for "build" - this way, the html files are pretty-printed. But I guess that mimosa uses something different for "watch". I had the config with prettyOutput: true in my config file but it didn't change what "mimosa watch -s" delivered.

You received this message because you are subscribed to a topic in the Google Groups "mimosajs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mimosajs/BHeTf728lbQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mimosajs+u...@googlegroups.com.

GMail

unread,
Oct 13, 2014, 7:39:56 AM10/13/14
to mimo...@googlegroups.com
I don't see anything in the code that would make build/watch different.  This is the config you have?

clientJadeStatic: { prettyOutput: true }

Sent from my iPhone

Michael Keller

unread,
Oct 13, 2014, 7:49:02 AM10/13/14
to mimo...@googlegroups.com
Yes, I have it exactely like that:
exports.config = {
  "modules": [
    "copy",
    "server",
    "jshint",
    "csslint",
    "require",
    "minify-js",
    "minify-css",
    "live-reload",
    "bower",
    "sass",
    "mimosa-server-template-compile"
  ],
  "server": {
    "defaultServer": {
      "enabled": true
    }
  },
  "sass": {
    "lib": require('node-sass'),
    "extensions": ["scss"],
    "includePaths": []
  },
  "liveReload": 
  {
    "additionalDirs": ["views"]  
  },
  "jade-static":
  {
    "pretty": true
  },
  clientJadeStatic: { prettyOutput: true }
}

GMail

unread,
Oct 13, 2014, 7:57:41 AM10/13/14
to mimo...@googlegroups.com
The jade-static block probably isn't doing anything for you.

You also don't have "client-jade-static" in your modules array.

Sent from my iPhone
--

Michael Keller

unread,
Oct 13, 2014, 8:14:37 AM10/13/14
to mimo...@googlegroups.com
I updated it to:
exports.config = {
  "modules": [
    "copy",
    "server",
    "jshint",
    "csslint",
    "require",
    "minify-js",
    "minify-css",
    "live-reload",
    "bower",
    "sass",
    "mimosa-server-template-compile",
    "client-jade-static"
  ],
  "server": {
    "defaultServer": {
      "enabled": true
    }
  },
  "sass": {
    "lib": require('node-sass'),
    "extensions": ["scss"],
    "includePaths": []
  },
  "liveReload": 
  {
    "additionalDirs": ["views"]  
  },
  "clientJadeStatic":
  {
    "prettyOutput": true
  }
}

but this didn't change anything

GMail

unread,
Oct 13, 2014, 8:46:02 AM10/13/14
to mimo...@googlegroups.com
Are these server or client templates?

Sent from my iPhone
--

Michael Keller

unread,
Oct 13, 2014, 10:25:33 AM10/13/14
to mimo...@googlegroups.com
server templates.. index.jade in the view folder.. and the html that is created is:
<!DOCTYPE html><html><head><title>Mimosa</title><link rel="stylesheet" href="/stylesheets/style.css?b=1413210282244"><script src="/socket.io/socket.io.js"></script><script src="/javascripts/reload-client.js"></script><script src="/javascripts/vendor/requirejs/require.js" data-main="/javascripts/main.js"></script></head><body><h3>Das ist ein Beispiel 2</h3></body></html>

David Bashford

unread,
Oct 13, 2014, 2:43:39 PM10/13/14
to mimo...@googlegroups.com
Ahh I see. so, here's the problem...

First, you can remove all the clientJadeStatic stuff from your config, its not being used.  As the name indicates, that is for client templates, not server ones.

When you run mimosa watch, you are simply getting the compiled template dynamically generated on the fly when you make a request to the URL.  So, you make request for /index which is to return index.jade.  It is compiled as part of the request and returned to you as the HTML that you see.  The HTML that is created is created in process, its never written to the file system.

You have server-template-compile in your application.  That only runs for mimosa build.  You are using mimosa's default server, that means you don't actually have a server of your own, which means you probably NEED your jade turned into HTML before you take the application and deploy it.   server-template-compile solves that problem by turning .jade into .html during a build.  Prior to a build there's no reason to generate that HTML because the .jade is served up dynamically by the server. 

So the problem you are having is that mimosa's default server isn't returning pretty html.  To be honest there's no reason it shouldn't since that is 100% a dev server.  Making the HTML optimized isn't necessary.

I'll take a look.


On Mon, Oct 13, 2014 at 10:25 AM, Michael Keller <cha...@gmail.com> wrote:
server templates.. index.jade in the view folder.. and the html that is created is:
<!DOCTYPE html><html><head><title>Mimosa</title><link rel="stylesheet" href="/stylesheets/style.css?b=1413210282244"><script src="/socket.io/socket.io.js"></script><script src="/javascripts/reload-client.js"></script><script src="/javascripts/vendor/requirejs/require.js" data-main="/javascripts/main.js"></script></head><body><h3>Das ist ein Beispiel 2</h3></body></html>

--

cha...@gmail.com

unread,
Oct 13, 2014, 4:41:00 PM10/13/14
to mimo...@googlegroups.com
jop - that's exactely it. Thanks a lot!

dbashford

unread,
Oct 13, 2014, 8:33:32 PM10/13/14
to mimo...@googlegroups.com, cha...@gmail.com
I've released mimosa v2.3.18 which includes pretty printing jade during mimosa watch when using dev server.

Thanks for bringing this up and working with me while I tried to figure it out!!

cha...@gmail.com

unread,
Oct 14, 2014, 2:14:50 AM10/14/14
to mimo...@googlegroups.com
YOU ROCK!
thanks a lot - works perfectly.
Reply all
Reply to author
Forward
0 new messages