These are chat archives for jescalan/roots

22nd
Jun 2015
Andrew Bradley
@cspotcode
Jun 22 2015 05:21
Is there a way to create “virtual files” in roots? Files that don’t exist on the filesystem but get injected into the pipeline by an extension, and then go through the whole categorization / compilation / writing process?
I’m looking for a way to read a directory of markdown files (not .jade files which use :marked; these are actually plain .md files) and render a single .jade template many times, each time passing it one of the markdown files.
Declan de Wet
@declandewet
Jun 22 2015 09:37

@cspotcode I'm not sure about that but you could add a second file to that process...

So you would have layout.jade, then post.jade which extends layout and include:markeds post.md

Sergio Forés
@t0t
Jun 22 2015 11:30
Trying to add jquery and slick carousel with npm install and got this error: [ReferenceError: window is not defined]. After adding npm packages I added these lines to app.coffee: jquery = require 'jquery' slick_carousel = require 'slick-carousel' I'm a bit lost... :frog:
My repo what's wrong implementing jquery & slick-carousel? Thanks.
Declan de Wet
@declandewet
Jun 22 2015 11:35
@t0t jquery and slick carousel appear to be browser modules, wheras app.coffee is a configuration file for Roots that operates in a Node.js-based environment... If you want to require node_modules in the browser, check out carrot/roots-browserify
and put those require statements inside assets/js/*.coffee
Sergio Forés
@t0t
Jun 22 2015 11:35
Thanks @declandewet ! I'll take a look
Jeff Escalante
@jescalan
Jun 22 2015 12:59
@t0t thanks so much! really glad you are enjoying it : )
Sergio Forés
@t0t
Jun 22 2015 13:12
I followed Roots Extension video tutorial, and was able to require Browserify to my project!. I like the idea of using only NPM for all the Extensions (instead of Bower.) Do you recomend to reference external libraries/plugins like jquery or slick-carousel directly to node_modules folder?. I'll try to add those libraries paths to app.coffee and require them...
Henry Snopek
@hhsnopek
Jun 22 2015 13:14
@t0t you can still use bower for your libraries, in fact you could use npm & bower at the same time!
to require a bower module from browserify just give the relative path
Sergio Forés
@t0t
Jun 22 2015 13:42
@hhsnopek I'm a big dummy... This is how I required them: main.coffee Where should I require them, on app.coffee?
Henry Snopek
@hhsnopek
Jun 22 2015 13:43
you can add them to your browserify files array within app.coffee if you want
it's a personal preference though
Sergio Forés
@t0t
Jun 22 2015 13:55
thanks for helping @hhsnopek, I've enqueued them like this: See the code but can't find the modules. What I'm doing wrong?
Henry Snopek
@hhsnopek
Jun 22 2015 14:00
the slick carousel path is incorrect
bower_components/slick/dist/slick.min.js is the path you're looking for
Sergio Forés
@t0t
Jun 22 2015 14:05
yes, thank you @hhsnopek ;)
Henry Snopek
@hhsnopek
Jun 22 2015 14:05
no problem :)
Sergio Forés
@t0t
Jun 22 2015 14:51
@hhsnopek excuse me one more time...
@hhsnopek $('.slider').slick() on main.coffee returns Uncaught ReferenceError: $ is not defined how do you define jquery? Do I have to use enclosures?
(my english is not so good as my spanish...) ;P
Henry Snopek
@hhsnopek
Jun 22 2015 14:52
you'll have to require anything in your main.coffee that needs to be assigned to a variable
Henry Snopek
@hhsnopek
Jun 22 2015 14:58
I would personal use npm to require jquery so that it resolves to var $ = require ('jquery') instead of the long bower path
Sergio Forés
@t0t
Jun 22 2015 14:59
yeah, It seems more clean and simple. I'll try now...
Andrew Bradley
@cspotcode
Jun 22 2015 15:05
@declandewet ok thanks. I could use a loop to read the .md directory and automatically stub out a corresponding post.jade file onto disc. It’s not quite as efficient as doing it all in ram, but it would work
Sergio Forés
@t0t
Jun 22 2015 15:10
@hhsnopek Finally I added jquery npm and required with $ = require ('jquery') It seems var was a reserved word
Henry Snopek
@hhsnopek
Jun 22 2015 15:10
are you using coffeescript or javascript?
coffeescript it's just: $ = require 'jquery'
Sergio Forés
@t0t
Jun 22 2015 15:12
coffescript in Roots, but jquery library and slick plugin comes in JS so I try to require them as they come. Now slick and jquery are running well
Henry Snopek
@hhsnopek
Jun 22 2015 15:13
yeah if you're using coffeescript, var is a reserved word
Sergio Forés
@t0t
Jun 22 2015 15:13
oh I see, thanks once again ;)
Henry Snopek
@hhsnopek
Jun 22 2015 15:13
yupp!