Skip to content

Commit

Permalink
Nue JS: Compiler whitespace fix. Fixes #218
Browse files Browse the repository at this point in the history
  • Loading branch information
tipiirai committed Feb 24, 2024
1 parent 7e37f02 commit ad6a292
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/nuejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuejs-core",
"version": "0.3.3",
"version": "0.3.4",

"description": "The Nue framework for building user interfaces",
"homepage": "https://nuejs.org",
Expand Down
5 changes: 4 additions & 1 deletion packages/nuejs/src/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ function compileNode(root) {
}

const quote = str => `'${str}'`
const arrwrap = str => '[' + str + ']'

function arrwrap(str) {
return '[' + str + ']'
}

function getHTML(str) {
str = str.trim()
Expand Down
5 changes: 4 additions & 1 deletion packages/nuejs/src/expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export function parseExpr(str, is_style) {

// normal string
if (i % 2 == 0) {
if (str) ret.push(str.includes("'") ? JSON.stringify(str) : `'${str}'`)
if (str) {
str = str.replace(/\s+/g, ' ')
ret.push(str.includes("'") ? JSON.stringify(str) : `'${str}'`)
}

// Object: { is-active: isActive() }
} else if (isObject(str.trim())) {
Expand Down
2 changes: 0 additions & 2 deletions packages/nuejs/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function parseError(e) {

// name == optional
function renderExpr(str, data, is_class) {
str = str.replaceAll('\n', '\\n')

try {
const arr = exec('[' + parseExpr(str) + ']', data)
return arr.filter(el => is_class ? el : el != null).join('')
Expand Down
2 changes: 1 addition & 1 deletion packages/nuejs/test/client/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1>Basics</h1>
<div id="basics"></div>

<script type="module">
import createApp from '../../src/nue.js'
import createApp from '../../src/browser/nue.js'
import { lib } from '../dist/basics.js'
const [ App, ...deps ] = lib
createApp(App, {}, deps).mount(basics)
Expand Down
4 changes: 3 additions & 1 deletion packages/nuejs/test/client/basics.nue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</main>

<div @name="refs-test">
<h3>Ref: { $refs.email.placeholder }</h3>
<h3>
Ref: { $refs.email.placeholder }
</h3>
<input name="email" placeholder="Your email">

<script>
Expand Down
2 changes: 1 addition & 1 deletion packages/nuejs/test/client/loops.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div id="plain"></div>

<script type="module">
import createApp from '../../src/nue.js'
import createApp from '../../src/browser/nue.js'
import { lib } from '../dist/loops.js'
const [ App, ...deps ] = lib
createApp(App, {}, deps).mount(plain)
Expand Down

0 comments on commit ad6a292

Please sign in to comment.