extensions.js 584 B

123456789101112131415161718
  1. exports.init = function (runtime) {
  2. runtime.register({
  3. file_join: function (value1, value2) {
  4. value1 = this.unbox(value1);
  5. value2 = this.unbox(value2);
  6. if (value1 && /\/$/.test(value1)) {
  7. value1 = value1.substring(0, value1.length - 1);
  8. }
  9. if (value2 && /^\//.test(value2)) {
  10. value2 = value2.substring(1);
  11. }
  12. var joined = value1 ? value1 + '/' + value2 : value2;
  13. return new Fashion.Text(joined, '');
  14. }
  15. });
  16. };