Skip to content
This repository was archived by the owner on May 9, 2018. It is now read-only.

Commit 102d336

Browse files
authored
Implemented template support for 'rel' property on href's schema jdorn#606 (#17)
1 parent aa611a8 commit 102d336

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

dist/jsoneditor.js

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/editor.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ JSONEditor.AbstractEditor = Class.extend({
177177

178178
// Template to generate the link href
179179
var href = this.jsoneditor.compileTemplate(data.href,this.template_engine);
180-
180+
var relTemplate = this.jsoneditor.compileTemplate(data.rel ? data.rel : data.href,this.template_engine);
181+
181182
// Template to generate the link's download attribute
182183
var download = null;
183184
if(data.download) download = data.download;
@@ -198,8 +199,9 @@ JSONEditor.AbstractEditor = Class.extend({
198199
// When a watched field changes, update the url
199200
this.link_watchers.push(function(vars) {
200201
var url = href(vars);
202+
var rel = relTemplate(vars);
201203
link.setAttribute('href',url);
202-
link.setAttribute('title',data.rel || url);
204+
link.setAttribute('title',rel || url);
203205
image.setAttribute('src',url);
204206
});
205207
}
@@ -218,8 +220,9 @@ JSONEditor.AbstractEditor = Class.extend({
218220
// When a watched field changes, update the url
219221
this.link_watchers.push(function(vars) {
220222
var url = href(vars);
223+
var rel = relTemplate(vars);
221224
link.setAttribute('href',url);
222-
link.textContent = data.rel || url;
225+
link.textContent = rel || url;
223226
media.setAttribute('src',url);
224227
});
225228
}
@@ -232,8 +235,9 @@ JSONEditor.AbstractEditor = Class.extend({
232235
// When a watched field changes, update the url
233236
this.link_watchers.push(function(vars) {
234237
var url = href(vars);
238+
var rel = relTemplate(vars);
235239
holder.setAttribute('href',url);
236-
holder.textContent = data.rel || url;
240+
holder.textContent = rel || url;
237241
});
238242
}
239243

0 commit comments

Comments
 (0)