2.5.16
https://codesandbox.io/s/6jnlpno3lw
์ด ๋ฌธ์ ๋ ๋ฃจํธ ์์๊ฐ ๋ค์ฌ ์ฐ๊ธฐ๋์ง ์๊ณ ์ฝง์์ผ์ด ์ฌ๋ฌ ์ค๋ก ๋ถํ ๋ ๊ฒฝ์ฐ ๋ฐ์ํฉ๋๋ค.
<template>
<div>
<p>{{
myVar
}}</p>
</div>
</template>
๋ฃจํธ ์์๊ฐ ๋ค์ฌ ์ฐ๊ธฐ ๋ ๊ฒฝ์ฐ์๋ง ์ฝง์์ผ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋ ๋๋ง๋ฉ๋๋ค.
<template>
<div>
<p>{{
myVar
}}</p>
</div>
</template>
๋ํ ์๋ํ๋ ๊ฒ์ ์ฝง์์ผ์ ํ ์ค์ ๋ฃ๊ณ ๋ฃจํธ ์์๋ฅผ ๋ค์ฌ ์ฐ์ง ์์ ๋์ ๋๋ค.
<template>
<div>
<p>{{ myVar }}</p>
</div>
</template>
์ฝง์์ผ์ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ธ๋ฉํด์ผํฉ๋๋ค.
์ฝง์์ผ์ ์ผ๋ฐ ํ ์คํธ๋ก ๋ ๋๋ง๋ฉ๋๋ค.
๋ด ์ฝ๋๋ฅผ ์์๊ฒ ๋ง๋ค๊ณ ์ถ์ ๊ธฐ ๋๋ฌธ์ ์ฝง์์ผ์ ์ฌ๋ฌ ์ค๋ก ๋๋๊ณ ๋ฃจํธ ์์์ ๋ค์ฌ ์ฐ๊ธฐ๋ฅผ ์ ๊ฑฐํ์ต๋๋ค.
<template>
์์ root element
์ฌ์ด์ ๋จ์ผ ๊ณต๋ฐฑ์ผ๋ก ์๋ํฉ๋๋ค.
<template> <p>{{
myVar
}}</p></template>
์ฌ์ด์ ๊ณต๋ฐฑ์ด ์์ต๋๋ค.
<template><p>{{
myVar
}}</p></template>
์ ๊ทธ๋ฐ ์์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํ๊ฒ ์ต๋๊น?
@syntacticsolutions ์ด๊ฒ์ ์ค์ํ์ง ์์ต๋๋ค. ์ฌ์ค ๊ทธ๊ฒ์ ๋ฒ๊ทธ์ ๋๋ค.
๊ฐ์ฌํฉ๋๋ค @DanielSharkov , ๋ฒ๊ทธ ์ฌ์ผํฉ๋๋ค.
๋ค์ฌ ์ฐ๊ธฐ๋ฅผ ์ฌ์ฉํ๋ ๋ค๋ฅธ ๋์์ ๊ทผ๋ณธ ์์ธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. https://github.com/yyx990803/de-indent/blob/master/index.js#L17 -L24
if (c === ' ' || c === '\t') {
type = c
cur = count(line, type)
if (cur < min) {
min = cur
}
} else {
return str
r์ ์ถ๊ฐํด์ผํ ๊น์? ํ ์คํธ ๋ณด๊ฐ ์ ๊ท์์ ํจํด :
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ๊ทธ๋ฐ ์์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํ๊ฒ ์ต๋๊น?