These are chat archives for jescalan/roots

20th
Apr 2016
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:19
Does anyone know a way to access dom variables through app.coffee or to pass variables from your js script to the app.coffee scripts?
Jeff Escalante
@jescalan
Apr 20 2016 15:20
yeah so
in your jade file
script= 'window.locals = ' + JSON.stringify(whatever_local)
this will attach locals to window, where js can pick em up
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:22
And then i will have access to that variable across my jade files?
Jeff Escalante
@jescalan
Apr 20 2016 15:45
uhh
werent you asking how to access with your js?
just use locals to put it into your jade files
then to make it accessible from js, use the above snippet to attach it ti window so it's accessible from js
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:46
no i want to basically access window.location.href from the app.coffee
Jeff Escalante
@jescalan
Apr 20 2016 15:46
oh, you already have access
ohhh wait nvm
that is not possible, app.coffee is a node script
that doesnt even make sense
app.coffee is your configuration file
jump one level up for me
whats the problem you are trying to solve
there's surely another way to do it
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:47
trying to have our base url stored in a variable so we can use it across our jade scripts
Jeff Escalante
@jescalan
Apr 20 2016 15:49
jade templates?
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:49
ya
Jeff Escalante
@jescalan
Apr 20 2016 15:49
and you mean base url, or that page's url?
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:49
This message was deleted
Jeff Escalante
@jescalan
Apr 20 2016 15:49
from inside a jade template, you can use _path to access that page's particlar path
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:49
base url
Jeff Escalante
@jescalan
Apr 20 2016 15:49
if you are trying to get a single base url as a local, just add it to locals in app.coffee
if you have different locals for different environments, make another app.coffee file for the second environment
app.production.coffee for example
and configure a different base url in there
Jordan Thompson
@jordanthomp81
Apr 20 2016 15:51
cool we were trying not to use multiple files but this will work. thanks for the help!
Jeff Escalante
@jescalan
Apr 20 2016 15:51
:+1:
if you have different locals for different environments, it's good practice to have different configurations
you can use NODE_ENV within your primary app.coffee to detect the environment and switch up the locals if you really are averse
Daniel Box
@dbox
Apr 20 2016 15:57
ROOTS IS AMAZING
Jeff Escalante
@jescalan
Apr 20 2016 15:57
:sparkling_heart: k
dont know how that k got in there but yeah
Daniel Box
@dbox
Apr 20 2016 15:59
pug :thumbsdown:
Jeff Escalante
@jescalan
Apr 20 2016 15:59
:dog:
Daniel Box
@dbox
Apr 20 2016 15:59
aw
Jeff Escalante
@jescalan
Apr 20 2016 15:59
they should have renamed it to doge
much better name
Daniel Box
@dbox
Apr 20 2016 15:59
totally
I was down with the jaed suggestion too
i feel like it happened so fast no one got a say
Gristel Periwinkle
@gristel
Apr 20 2016 18:10
Hi.. I have a project with some modules. Is there any way I can set the default page to /module1/index.jade instead of /views/index.jade?
Ben Styles
@benadamstyles
Apr 20 2016 18:38
What do you mean by default page? Homepage? That's a server issue really, but you could put a views/index.jade that just includes /module1/index.jade
Gristel Periwinkle
@gristel
Apr 20 2016 18:39
Yes that’s why I figured. But I can’t do anything about server config, so I was doubting between an include or a location.replace()
Ben Styles
@benadamstyles
Apr 20 2016 18:40
Well in include is static, so no browser redirect/reload required
*an include
Gristel Periwinkle
@gristel
Apr 20 2016 18:40
better option indeed
thanks!
Ben Styles
@benadamstyles
Apr 20 2016 18:40
np
Jeff Escalante
@jescalan
Apr 20 2016 21:30
roots uses charge locally to serve sites
charge includes a piece of middleware called pathologist
you can use this to key in a custom route as well
in roots it would be server: { routes: { 'index.html': 'xxx' } }