dbashford / mimosa-server-template-compile

A mimosa module for compiling server templates as part of a build
3 stars 1 forks source link

Relative paths #4

Open xixixao opened 10 years ago

xixixao commented 10 years ago

Not sure how, but it would be cool to point out that relative paths should be used inside views.

link(rel='stylesheet', href='css/style.css' + cachebust)
dbashford commented 10 years ago

This a request of mimosa-server and how the embedded server works? Or does it have something to do with server-template-compile?

xixixao commented 10 years ago

Well, I ran into this when I wanted to serve the website statically, in which case I was using this module. I assume this isn't a problem when actually serving the website, in which case the absolute paths are preferred.

dbashford commented 10 years ago

Just so I understand...

You are serving the website statically, post mimosa build and without mimosa involved, and you are using this module to compile the dynamic templates to static ones, and when you do that the paths need to be relative?

xixixao commented 10 years ago

Yes.

xixixao commented 10 years ago

Any updates on this, advice? I might change my skeletons that I intend to make available as static deploy, to use relative paths. But better, and I have seen this somewhere... (maybe Nette, PHP framework), is to pass in baseUrl, that could be correctly handled when you compile the templates:

link(rel='stylesheet', href='{baseUrl}css/style.css' + cachebust)

so that if a template is inside a directory, the jade gets baseUrl as ../ and in config you can set what the top url is supposed to be.

dbashford commented 10 years ago

I'm traveling for work this week so I'm a little booked. One thing that would help me understand this is if you could throw together a simple app illustrating the problem. I think I get it, but don't want to advise poorly.

If the baseUrl thing works for you, is that something you could add to serverTemplate.locals? Modify your jade templates to take baseUrl and pass it in?

xixixao commented 10 years ago

If the baseUrl is absolute, then yes, otherwise no. (I'll try to put the app together, do subfolders in views even work?)

dbashford commented 10 years ago

I don't believe subfolders work for the default server, but I may be misunderstanding the issue I put in awhile back. I may never double back to that issue. The default server isn't meant to be robust enough to handle complex cases.

Or are you talking about something else?

I'm back at mimosa 2.0 this week after a week away from it while traveling. If I get some dead time I'll take a peek at this.

xixixao commented 10 years ago

Yeah, that's what I meant.

For this, it's important what people need in real situations, mine is just one use case, and then it's just about the defaults, really (nothing stops devs from changing that URL).