Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.core
Commits
ea194c88
Commit
ea194c88
authored
May 04, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import ICanHaz (including mustache) to templating
parent
b21deede
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
jQuery/vifib/static/js/ICanHaz.min.js
jQuery/vifib/static/js/ICanHaz.min.js
+11
-0
No files found.
jQuery/vifib/static/js/ICanHaz.min.js
0 → 100644
View file @
ea194c88
(
function
(){
var
q
=
function
(){
function
c
(
a
){
return
(
""
+
a
).
replace
(
/&
(?!\w
+;
)
|
[
<>"'
]
/g
,
function
(
a
){
return
k
[
a
]
||
a
})}
var
e
=
Object
.
prototype
.
toString
;
Array
.
isArray
=
Array
.
isArray
||
function
(
a
){
return
"
[object Array]
"
==
e
.
call
(
a
)};
var
i
=
String
.
prototype
.
trim
,
g
;
if
(
i
)
g
=
function
(
a
){
return
null
==
a
?
""
:
i
.
call
(
a
)};
else
{
var
h
,
m
;
/
\S
/
.
test
(
"
\
u00a0
"
)?(
h
=
/^
[\s\x
A0
]
+/
,
m
=
/
[\s\x
A0
]
+$/
):(
h
=
/^
\s
+/
,
m
=
/
\s
+$/
);
g
=
function
(
a
){
return
null
==
a
?
""
:
a
.
toString
().
replace
(
h
,
""
).
replace
(
m
,
""
)}}
var
k
=
{
"
&
"
:
"
&
"
,
"
<
"
:
"
<
"
,
"
>
"
:
"
>
"
,
'
"
'
:
"
"
"
,
"
'
"
:
"
'
"
},
o
=
{},
p
=
function
(){};
p
.
prototype
=
{
otag
:
"
{{
"
,
ctag
:
"
}}
"
,
pragmas
:{},
buffer
:[],
pragmas_implemented
:{
"
IMPLICIT-ITERATOR
"
:
!
0
},
context
:{},
render
:
function
(
a
,
d
,
b
,
f
){
if
(
!
f
)
this
.
context
=
d
,
this
.
buffer
=
[];
if
(
this
.
includes
(
""
,
a
)){
var
a
=
this
.
render_pragmas
(
a
),
j
=
this
.
render_section
(
a
,
d
,
b
);
!
1
===
j
&&
(
j
=
this
.
render_tags
(
a
,
d
,
b
,
f
));
if
(
f
)
return
j
;
this
.
sendLines
(
j
)}
else
{
if
(
f
)
return
a
;
this
.
send
(
a
)}},
send
:
function
(
a
){
""
!==
a
&&
this
.
buffer
.
push
(
a
)},
sendLines
:
function
(
a
){
if
(
a
)
for
(
var
a
=
a
.
split
(
"
\n
"
),
d
=
0
;
d
<
a
.
length
;
d
++
)
this
.
send
(
a
[
d
])},
render_pragmas
:
function
(
a
){
if
(
!
this
.
includes
(
"
%
"
,
a
))
return
a
;
var
d
=
this
,
b
=
this
.
getCachedRegex
(
"
render_pragmas
"
,
function
(
a
,
d
){
return
RegExp
(
a
+
"
%([
\\
w-]+) ?([
\\
w]+=[
\\
w]+)?
"
+
d
,
"
g
"
)});
return
a
.
replace
(
b
,
function
(
a
,
b
,
e
){
if
(
!
d
.
pragmas_implemented
[
b
])
throw
{
message
:
"
This implementation of mustache doesn't understand the '
"
+
b
+
"
' pragma
"
};
d
.
pragmas
[
b
]
=
{};
e
&&
(
a
=
e
.
split
(
"
=
"
),
d
.
pragmas
[
b
][
a
[
0
]]
=
a
[
1
]);
return
""
})},
render_partial
:
function
(
a
,
d
,
b
){
a
=
g
(
a
);
if
(
!
b
||
void
0
===
b
[
a
])
throw
{
message
:
"
unknown_partial '
"
+
a
+
"
'
"
};
return
!
d
||
"
object
"
!=
typeof
d
[
a
]?
this
.
render
(
b
[
a
],
d
,
b
,
!
0
):
this
.
render
(
b
[
a
],
d
[
a
],
b
,
!
0
)},
render_section
:
function
(
a
,
d
,
b
){
if
(
!
this
.
includes
(
"
#
"
,
a
)
&&!
this
.
includes
(
"
^
"
,
a
))
return
!
1
;
var
f
=
this
,
j
=
this
.
getCachedRegex
(
"
render_section
"
,
function
(
a
,
b
){
return
RegExp
(
"
^([
\\
s
\\
S]*?)
"
+
a
+
"
(
\\
^|
\\
#)
\\
s*(.+)
\\
s*
"
+
b
+
"
\n
*([
\\
s
\\
S]*?)
"
+
a
+
"
\\
/
\\
s*
\\
3
\\
s*
"
+
b
+
"
\\
s*([
\\
s
\\
S]*)$
"
,
"
g
"
)});
return
a
.
replace
(
j
,
function
(
a
,
j
,
e
,
c
,
g
,
h
){
var
a
=
j
?
f
.
render_tags
(
j
,
d
,
b
,
!
0
):
""
,
h
=
h
?
f
.
render
(
h
,
d
,
b
,
!
0
):
""
,
n
,
c
=
f
.
find
(
c
,
d
);
"
^
"
===
e
?
n
=!
c
||
Array
.
isArray
(
c
)
&&
0
===
c
.
length
?
f
.
render
(
g
,
d
,
b
,
!
0
):
""
:
"
#
"
===
e
&&
(
n
=
Array
.
isArray
(
c
)?
f
.
map
(
c
,
function
(
a
){
return
f
.
render
(
g
,
f
.
create_context
(
a
),
b
,
!
0
)}).
join
(
""
):
f
.
is_object
(
c
)?
f
.
render
(
g
,
f
.
create_context
(
c
),
b
,
!
0
):
"
function
"
==
typeof
c
?
c
.
call
(
d
,
g
,
function
(
a
){
return
f
.
render
(
a
,
d
,
b
,
!
0
)}):
c
?
f
.
render
(
g
,
d
,
b
,
!
0
):
""
);
return
a
+
n
+
h
})},
render_tags
:
function
(
a
,
d
,
b
,
f
){
for
(
var
j
=
this
,
e
=
function
(){
return
j
.
getCachedRegex
(
"
render_tags
"
,
function
(
a
,
b
){
return
RegExp
(
a
+
"
(=|!|>|&|
\\
{|%)?([^#
\\
^]+?)
\\
1?
"
+
b
+
"
+
"
,
"
g
"
)})},
g
=
e
(),
h
=
function
(
a
,
f
,
h
){
switch
(
f
){
case
"
!
"
:
return
""
;
case
"
=
"
:
return
j
.
set_delimiters
(
h
),
g
=
e
(),
""
;
case
"
>
"
:
return
j
.
render_partial
(
h
,
d
,
b
);
case
"
{
"
:
case
"
&
"
:
return
j
.
find
(
h
,
d
);
default
:
return
c
(
j
.
find
(
h
,
d
))}},
a
=
a
.
split
(
"
\n
"
),
i
=
0
;
i
<
a
.
length
;
i
++
)
a
[
i
]
=
a
[
i
].
replace
(
g
,
h
,
this
),
f
||
this
.
send
(
a
[
i
]);
if
(
f
)
return
a
.
join
(
"
\n
"
)},
set_delimiters
:
function
(
a
){
a
=
a
.
split
(
"
"
);
this
.
otag
=
this
.
escape_regex
(
a
[
0
]);
this
.
ctag
=
this
.
escape_regex
(
a
[
1
])},
escape_regex
:
function
(
a
){
if
(
!
arguments
.
callee
.
sRE
)
arguments
.
callee
.
sRE
=
RegExp
(
"
(
\\
/|
\\
.|
\\
*|
\\
+|
\\
?|
\\
||
\\
(|
\\
)|
\\
[|
\\
]|
\\
{|
\\
}|
\\\\
)
"
,
"
g
"
);
return
a
.
replace
(
arguments
.
callee
.
sRE
,
"
\\
$1
"
)},
find
:
function
(
a
,
d
){
function
b
(
a
){
return
!
1
===
a
||
0
===
a
||
a
}
var
a
=
g
(
a
),
f
;
if
(
a
.
match
(
/
([
a-z_
]
+
)\.
/ig
)){
var
c
=
this
.
walk_context
(
a
,
d
);
b
(
c
)
&&
(
f
=
c
)}
else
b
(
d
[
a
])?
f
=
d
[
a
]:
b
(
this
.
context
[
a
])
&&
(
f
=
this
.
context
[
a
]);
return
"
function
"
==
typeof
f
?
f
.
apply
(
d
):
void
0
!==
f
?
f
:
""
},
walk_context
:
function
(
a
,
d
){
for
(
var
b
=
a
.
split
(
"
.
"
),
f
=
void
0
!=
d
[
b
[
0
]]?
d
:
this
.
context
,
c
=
f
[
b
.
shift
()];
void
0
!=
c
&&
0
<
b
.
length
;)
f
=
c
,
c
=
c
[
b
.
shift
()];
return
"
function
"
==
typeof
c
?
c
.
apply
(
f
):
c
},
includes
:
function
(
a
,
d
){
return
-
1
!=
d
.
indexOf
(
this
.
otag
+
a
)},
create_context
:
function
(
a
){
if
(
this
.
is_object
(
a
))
return
a
;
var
d
=
"
.
"
;
if
(
this
.
pragmas
[
"
IMPLICIT-ITERATOR
"
])
d
=
this
.
pragmas
[
"
IMPLICIT-ITERATOR
"
].
iterator
;
var
b
=
{};
b
[
d
]
=
a
;
return
b
},
is_object
:
function
(
a
){
return
a
&&
"
object
"
==
typeof
a
},
map
:
function
(
a
,
d
){
if
(
"
function
"
==
typeof
a
.
map
)
return
a
.
map
(
d
);
for
(
var
b
=
[],
c
=
a
.
length
,
e
=
0
;
e
<
c
;
e
++
)
b
.
push
(
d
(
a
[
e
]));
return
b
},
getCachedRegex
:
function
(
a
,
d
){
var
b
=
o
[
this
.
otag
];
b
||
(
b
=
o
[
this
.
otag
]
=
{});
var
c
=
b
[
this
.
ctag
];
c
||
(
c
=
b
[
this
.
ctag
]
=
{});
(
b
=
c
[
a
])
||
(
b
=
c
[
a
]
=
d
(
this
.
otag
,
this
.
ctag
));
return
b
}};
return
{
name
:
"
mustache.js
"
,
version
:
"
0.4.0
"
,
to_html
:
function
(
a
,
c
,
b
,
f
){
var
e
=
new
p
;
if
(
f
)
e
.
send
=
f
;
e
.
render
(
a
,
c
||
{},
b
);
if
(
!
f
)
return
e
.
buffer
.
join
(
"
\n
"
)}}}();(
function
(){
var
c
=
{
VERSION
:
"
0.10
"
,
templates
:{},
$
:
"
undefined
"
!==
typeof
window
?
window
.
jQuery
||
window
.
Zepto
||
null
:
null
,
addTemplate
:
function
(
e
,
i
){
if
(
"
object
"
===
typeof
e
)
for
(
var
g
in
e
)
this
.
addTemplate
(
g
,
e
[
g
]);
else
c
[
e
]?
console
.
error
(
"
Invalid name:
"
+
e
+
"
.
"
):
c
.
templates
[
e
]?
console
.
error
(
'
Template "
'
+
e
+
'
" exists
'
):(
c
.
templates
[
e
]
=
i
,
c
[
e
]
=
function
(
g
,
i
){
var
g
=
g
||
{},
k
=
q
.
to_html
(
c
.
templates
[
e
],
g
,
c
.
templates
);
return
c
.
$
&&!
i
?
c
.
$
(
k
):
k
})},
clearAll
:
function
(){
for
(
var
e
in
c
.
templates
)
delete
c
[
e
];
c
.
templates
=
{}},
refresh
:
function
(){
c
.
clearAll
();
c
.
grabTemplates
()},
grabTemplates
:
function
(){
var
e
,
i
=
document
.
getElementsByTagName
(
"
script
"
),
g
,
h
=
[];
for
(
e
=
0
,
l
=
i
.
length
;
e
<
l
;
e
++
)
if
((
g
=
i
[
e
])
&&
g
.
innerHTML
&&
g
.
id
&&
(
"
text/html
"
===
g
.
type
||
"
text/x-icanhaz
"
===
g
.
type
))
c
.
addTemplate
(
g
.
id
,
""
.
trim
?
g
.
innerHTML
.
trim
():
g
.
innerHTML
.
replace
(
/^
\s
+/
,
""
).
replace
(
/
\s
+$/
,
""
)),
h
.
unshift
(
g
);
for
(
e
=
0
,
l
=
h
.
length
;
e
<
l
;
e
++
)
h
[
e
].
parentNode
.
removeChild
(
h
[
e
])}};
"
undefined
"
!==
typeof
require
?
module
.
exports
=
c
:
window
.
ich
=
c
;
"
undefined
"
!==
typeof
document
&&
(
c
.
$
?
c
.
$
(
function
(){
c
.
grabTemplates
()}):
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
(){
c
.
grabTemplates
()},
!
0
))})()})();
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