Skip to content

Instantly share code, notes, and snippets.

@kvz
Last active May 10, 2016 11:39
Show Gist options
  • Select an option

  • Save kvz/a566ba3be4a3faf7d6e6 to your computer and use it in GitHub Desktop.

Select an option

Save kvz/a566ba3be4a3faf7d6e6 to your computer and use it in GitHub Desktop.
Proposal for (partial) template includes
{
include_template: "a", // <-- full template, used as a base
is_video: {
use: ":original",
robot: "/file/filter",
accepts: [
[
"${file.mime}",
"regex",
"video"
],
],
error_on_decline:false
},
is_image: {
use: ":original",
robot: "/file/filter",
accepts: [
[
"${file.mime}",
"regex",
"image",
],
],
error_on_decline: false
},
include_template_partial: "c.video_encode", // <-- include just 1 named step
video_encode: {
use: "is_video", // <-- override its `use` parameter to connect the chain
},
include_template_partial: "c.image_resize",
image_resize: {
use: "is_image",
},
store: { // <-- was already inside template "a"
// <-- override its `use` parameter to connect the chain
use: ["video_encode", "image_resize", ":original"],
},
}
@kvz
Copy link
Author

kvz commented Jun 5, 2015

I think we could have a few versioned public templates that everyone can use. Maybe in an open source repo at GitHub so people can contribute new ones / better ideas. So for instance:

include_template_partial: "transloadit-2015-06-05.hls_720p",
hls_720p: {
  use: "is_video",
}

@avokhmin
Copy link

avokhmin commented Jun 5, 2015

looks great.

All logic of processing can be in the separate templates, but store in the main.

Maybe in an open source repo at GitHub so people can contribute new ones / better ideas.

πŸ‘ , also will be more examples.

What will be if names are equal?

  include_template_partial: "video-template-id.review",
  include_template_partial: "image-template-id.review",

@kvz
Copy link
Author

kvz commented Jun 5, 2015

Good point, I guess:

include_template_partials: [ "video-template-id.review", "image-template-id.review" ]

is the way to fly ☺️

We'll make use mandatory, so it's not important in what order the partials are inserted (as you probably know the order of items in objects isn't guaranteed by ecma, so we wanted to make use mandatory already anyway)

@tim-kos
Copy link

tim-kos commented Jun 6, 2015

I like the partials idea. πŸ‘

@avokhmin
Copy link

avokhmin commented Jul 7, 2015

πŸ‘

@k41n
Copy link

k41n commented Jul 7, 2015

πŸ‘

@recurser
Copy link

recurser commented Jul 7, 2015

πŸ‘

@kvz
Copy link
Author

kvz commented Nov 4, 2015

Just to add to this idea - maybe we use something like https://github.com/hashicorp/go-getter - so that template partials could be sourced from any location. Gist, http, git, etc.

@Prinzhorn
Copy link

I had a similar idea last week but it's basically not THAT similar https://gist.github.com/Prinzhorn/8af8b7f56d72431f9945552bca06f962
I just want to keep things DRY and think that would be something that can be added really easily. Basically with the exact same logic that we already have when sending steps along with the upload (it's just a matter of merging those objects).

To be honest looking at the json in this gist it's not obvious to me what it's supposed to do. I get the idea that having public templates would be beneficial for everyone, but then the templates on transloadit are not self contained any more and I need to do a shitton of work in my head to put everything together. You wouldn't be able to understand the template just by looking at it.

@kvz
Copy link
Author

kvz commented May 10, 2016

@Prinzhorn I see where the two diverge now, your approach is interesting and easier to add indeed. I'll discuss with the team if I'm not overlooking anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment