question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Template not working

See original GitHub issue

Hello,

I’m trying to create a custom template that is left to right, but 2 rows of images tall.

My gulpfile.js:

var gulp = require('gulp');
var spritesmith = require('gulp.spritesmith');
var layout = require('layout');

gulp.task('add-custom-layout', function() {
    spritesmith.layout = layout;
    spritesmith.layout.addAlgorithm('2-row', require('./sprites/algorithms/2-row.js'));
});

gulp.task('sprite-sleeve', function() {
    var spriteData = gulp.src('./sprites/src/sleeve/*.png').pipe(spritesmith({
        imgName: './sprites/generated/sleeve.png',
        cssName: './src/css/filter-panel/sleeve/sleeve-sprite.scss',
        algorithm: '2-row',
        cssSpritesheetName: 'sleeve',
        cssVarMap: function (sprite) {
            sprite.name = 'vs-icon-' + sprite.name;
        },
        cssTemplate: './sprites/icon.scss.handlebars'
    }));
    return spriteData.pipe(gulp.dest('./'));
});

gulp.task('sprite', ['add-custom-layout', 'sprite-sleeve']);
gulp.task('default', ['sprite']);

My custom algorithm 2-row.js is literally just a copy and paste of the left-right algorithm.

The error is on https://github.com/twolfson/layout/blob/master/lib/layout.js line 21. Essentially my algorithm cannot be found.

I tried to debug and find the root cause. It seems like even though i add the algorithm to the layout module imported into my package, that layout doesn’t ever get put through to the actual spritesmith code https://github.com/Ensighten/spritesmith/blob/master/src/smith.js::processImages method.

Any ideas on the issue? Any errors in my code? Are there any examples of working custom templates? The documentation was a bit light on this area.

Thank you for your time and really loving spritesmith on the whole!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
salohcinzerocommented, May 18, 2016

I tried that out just now and that doesn’t work very well for my specific use case. Say i have 10 icons. I would want a layout like:

x x x x x
x x x x x

No empty/wasted space.

binary-tree outputs something like:

x x x x
x x x o
x x x o

Which has 2 empty spots. Does that make sense?

0reactions
twolfsoncommented, May 18, 2016

Ah, k. I guess it isn’t a perfect algorithm (hard problem to solve) =/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom page template not working - WordPress Stack Exchange
A safe way to create page templates is to copy an existing template from your theme folder, rename the file, ...
Read more >
Custom pages and templates not loading - WordPress.org
I try to create a custom page for this page. But it will not load any static html. I have created a file...
Read more >
wordpress page template is not working - Stack Overflow
I have creat page name Blog and assign it a custom template from dropdown Blog,But when I click on navigation element Blog it...
Read more >
Custom page templates not working - Roots Discourse
So I'm asking…if I'm using the current version of Roots…if I have a page called “products” - how do I go about creating...
Read more >
Where are my custom templates? - Microsoft Support
Learn how to find your custom templates created with earlier versions of Office and ... Personal tab showing your custom template after you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found