Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
typescript
json2html
Commits
ee4c20fa
Commit
ee4c20fa
authored
Oct 14, 2020
by
Zéfling
🎨
Browse files
fix attributes render
parent
ca9ac460
Changes
4
Hide whitespace changes
Inline
Side-by-side
.editorconfig
View file @
ee4c20fa
# Editor configuration, see http://editorconfig.org
# Editor configuration, see http
s
://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size =
2
indent_size =
4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[*.json]
indent_size = 2
CHANGELOG.md
View file @
ee4c20fa
# Changelog of json2html-lib
## V0.0.2 (2020-10-14)
-
Fix attributs render
## V0.0.1 (2020-10-14)
-
initial release
projects/json2html/package.json
View file @
ee4c20fa
{
"name"
:
"json2html-lib"
,
"version"
:
"0.0.
1
"
,
"version"
:
"0.0.
2
"
,
"license"
:
"MIT"
,
"repository"
:
{
"type"
:
"git"
,
...
...
projects/json2html/src/lib/json2html.ts
View file @
ee4c20fa
...
...
@@ -79,30 +79,32 @@ export class Json2html {
private
_generateAttrs
(
lvl
:
number
,
json
:
Json2htmlRef
)
{
let
string
=
''
;
const
attrs
=
json
.
attrs
;
if
(
json
.
attrs
&&
Object
.
keys
(
json
.
attrs
).
length
)
{
for
(
const
id
in
json
.
attrs
)
{
if
(
json
.
attrs
[
id
]
!==
undefined
)
{
if
(
attrs
&&
Object
.
keys
(
attrs
).
length
)
{
for
(
const
id
in
attrs
)
{
if
(
attrs
[
id
]
!==
undefined
)
{
let
attr
=
''
;
switch
(
this
.
options
.
attrPosition
)
{
case
'
inline
'
:
string
+=
'
'
;
attr
+=
'
'
;
break
;
case
'
space
'
:
string
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
attr
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
?
`\n
${
this
.
_getSpacing
(
lvl
+
1
)}
`
:
string
+=
'
'
;
break
;
case
'
alignTag
'
:
string
+=
string
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
attr
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
?
`\n
${
this
.
_getSpacing
(
lvl
,
1
)}
`
:
'
'
;
break
;
case
'
alignFirstAttr
'
:
string
+=
string
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
?
`\n
${
this
.
_getSpacing
(
lvl
,
this
.
json
.
tag
.
length
+
2
)}
`
attr
+=
string
&&
this
.
options
.
indent
&&
this
.
_hasMultiline
()
?
`\n
${
this
.
_getSpacing
(
lvl
,
json
.
tag
.
length
+
2
)}
`
:
'
'
;
break
;
}
string
+=
`
${
id
}${
json
.
attrs
[
id
]
!==
null
||
json
.
attrs
[
id
]
?
`="
${
json
.
attrs
[
id
]}
"`
:
''
}
`
;
attr
+=
`
${
id
}${
attrs
[
id
]
!==
null
||
attrs
[
id
]
?
`="
${
attrs
[
id
]}
"`
:
''
}
`
;
string
+=
attr
;
}
}
}
...
...
Write
Preview
Supports
Markdown
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