Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cto
g1
Commits
fcd32161
Commit
fcd32161
authored
Apr 22, 2019
by
Tejesh
🖖
Browse files
format
parent
d505500f
Pipeline
#83676
failed with stage
in 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/template.js
View file @
fcd32161
...
...
@@ -7,14 +7,14 @@ function dependency_accumulator(current_template, self, data, options) {
var
dependency_selectors
=
$
(
current_template
)
.
data
(
'
subtemplates
'
)
.
split
(
'
,
'
)
.
filter
(
function
(
selector
)
{
.
filter
(
function
(
selector
)
{
return
!
$
(
selector
).
data
(
'
template.compiled
'
)
})
return
$
.
when
.
apply
(
$
,
dependency_selectors
.
map
(
function
(
dependency_selector
)
{
dependency_selectors
.
map
(
function
(
dependency_selector
)
{
return
dependency_accumulator
(
dependency_selector
,
self
,
...
...
@@ -23,10 +23,10 @@ function dependency_accumulator(current_template, self, data, options) {
)
})
)
.
then
(
function
()
{
.
then
(
function
()
{
return
$
.
when
.
apply
(
$
,
dependency_selectors
.
map
(
function
(
sub_temp_selector
)
{
dependency_selectors
.
map
(
function
(
sub_temp_selector
)
{
return
execute_render
(
$
(
sub_temp_selector
,
self
),
data
,
options
)
})
)
...
...
@@ -42,7 +42,7 @@ export function template(data, options) {
// Pre-create the template rendering function
// Store this in .data('template.function')
findall
(
self
,
selector
).
each
(
function
()
{
findall
(
self
,
selector
).
each
(
function
()
{
var
$this
=
$
(
this
)
// If we want to dispose the last target, just dispose it.
if
(
data
===
'
dispose
'
)
{
...
...
@@ -80,10 +80,10 @@ function execute_render($this, data, options) {
// If the AJAX load succeeds, render the loaded template
// Else render the contents, with an additional xhr variable
return
$
.
get
(
src
)
.
done
(
function
(
html
)
{
.
done
(
function
(
html
)
{
make_template
(
$this
,
html
,
data
,
options
)
})
.
fail
(
function
(
xhr
)
{
.
fail
(
function
(
xhr
)
{
data
.
xhr
=
xhr
make_template
(
$this
,
$this
.
html
(),
data
,
options
)
})
...
...
@@ -156,7 +156,7 @@ function make_template($this, html, data, default_options) {
template
.
engines
=
{}
// The default engine uses jQuery
template
.
engines
[
'
default
'
]
=
template
.
engines
[
'
jquery
'
]
=
function
(
template
.
engines
[
'
default
'
]
=
template
.
engines
[
'
jquery
'
]
=
function
(
$this
,
target
,
html
...
...
@@ -176,7 +176,7 @@ template.engines['default'] = template.engines['jquery'] = function(
}
/* globals morphdom */
template
.
engines
[
'
vdom
'
]
=
function
(
$this
,
target
,
html
)
{
template
.
engines
[
'
vdom
'
]
=
function
(
$this
,
target
,
html
)
{
// If no target is specified, use the previous target, if any
target
=
target
||
$this
.
data
(
_prev_created
)
// If a target is specified, wrap the HTML with the target node.
...
...
@@ -187,7 +187,7 @@ template.engines['vdom'] = function($this, target, html) {
$target
=
$
(
target
)
var
node
=
$target
.
get
(
0
)
tag_open
=
'
<
'
+
node
.
nodeName
$
.
each
(
node
.
attributes
,
function
()
{
$
.
each
(
node
.
attributes
,
function
()
{
tag_open
+=
'
'
+
this
.
name
+
'
=
'
+
this
.
value
})
tag_open
+=
'
>
'
...
...
@@ -201,7 +201,7 @@ template.engines['vdom'] = function($this, target, html) {
tag_close
=
'
</div>
'
$target
=
$
(
tag_open
+
tag_close
).
insertBefore
(
$this
)
}
$target
.
each
(
function
()
{
$target
.
each
(
function
()
{
morphdom
(
this
,
tag_open
+
html
+
tag_close
)
})
return
$target
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment