We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    had a funny though - does anyone think it's possible or has a solution to be able to use handlebars templates/partials etc as static files for templates/chunks/etc within the modx?
    Seems like (for a start) we need some kind of plugin to translate all the {{> }} to [[$ ]] etc.

    But it would be much better to be able to develop within a handlebars/moustache project and just "depoly" rather than have to copy everything manually into modx chunks/snippets/templates ~ what have you.

    Specifically I am working a lot with Foundation projects & workflow. it would be handy to be able to get gulp to fire a plugin or something in modx to update /clear cache etc.

    Thoughts anyone?
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
    • Pdotools comes with a fenom parser, which is similar but a different templating language. It's definitely possible to do funny things with the parser like that.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 26503
        • 620 Posts
        It was actually pretty straight forward to make some additions to the gulpfile to make things happen:

        // Build the "dist" folder by running all of the below tasks
        gulp.task('build',
         gulp.series(clean, gulp.parallel(pages, sass, javascript, images, copy, flowplayer, vendor, _build, chunks, snippets)));
        
        // Build the site, run the server, and watch for file changes
        gulp.task('default',
          gulp.series('build', server, watch));
        
        // Delete the "dist" folder
        // This happens every time a build starts
        function clean(done) {
          rimraf(PATHS.dist + '/assets/css', done);
          rimraf(PATHS.dist + '/assets/img', done);
          rimraf(PATHS.dist + '/assets/js', done);
          rimraf(PATHS.dist + '/_build', done);
          rimraf(PATHS.dist + '/assets/views', done);
        }
        
        function chunks() {
          let files = [
            'src/layouts/**/*',
            'src/partials/**/*'
          ];
          return gulp.src(files, {base:'src/'})
          .pipe(replace('{{> ', '[[$'))
          .pipe(replace('}}', ']]'))
          .pipe(gulp.dest(PATHS.dist + '/assets/views'));
        }
        function snippets() {
          let files = [
            'src/snippets/**/*',
            'src/plugins/**/*'
          ];
          return gulp.src(files, {base:'src/'})
          .pipe(gulp.dest(PATHS.dist + '/assets/views'));
        }
        
        
        
        // Watch for changes to static assets, pages, Sass, and JavaScript
        function watch() {
          let watch_chunks = [
            'src/layouts/**/*',
            'src/partials/**/*'
          ];
          let watch_snippets = [
            'src/snippets/**/*',
            'src/plugins/**/*'
          ];
          gulp.watch(PATHS.assets, copy);
          gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, browser.reload));
          gulp.watch('src/{layouts,partials}/**/*.html').on('all', gulp.series(resetPages, pages, browser.reload));
          gulp.watch('src/assets/scss/**/*.scss').on('all', sass);
          gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(javascript, browser.reload));
          gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
          gulp.watch('src/assets/js/vendor/**').on('all', gulp.series(vendor, browser.reload));
          gulp.watch('src/_build/**').on('all', gulp.series(_build, browser.reload));
          gulp.watch(watch_chunks).on('all', gulp.series(chunks, browser.reload));
          gulp.watch(watch_snippets).on('all', gulp.series(snippets, browser.reload));
        }
        


        only thing missing here is a regex for replacement ~ the simple string replace works for now but will probably run into issues.

        just working on a snippet that will create all the chunks/templates/categories and snippets in modx from the directory structure that gets built in the distribution path.

        the last part would be some kind of plugin or watcher that will that will shwack the modx cache when changes are detected.

        The one thing I am not sure of at this point is under what conditions does modx save a static file to the database? When it has to rebuild the cache, does it read the static files and update the db?
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 3749
          • 24,544 Posts
          just working on a snippet that will create all the chunks/templates/categories and snippets in modx from the directory structure that gets built in the distribution path.

          I wonder if MyComponent would work for your use case. It will create all those, and they can be static. You might also look at the DirWalker class, which will create an array from a directory structure with the full path as the key and the file name as the value.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting