Merge branch 'master' into stateful-components2
This commit is contained in:
commit
994a51a1f0
8 changed files with 43 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
nimcache/
|
||||
/tests/tester
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Karax -- Single page applications in Nim
|
||||
========================================
|
||||
Karax – Single page applications in Nim |travis|
|
||||
================================================
|
||||
|
||||
Karax is a framework for developing single page applications in Nim.
|
||||
It's still in heavy development, so keep in mind that the API is subject
|
||||
|
|
@ -33,3 +33,6 @@ Goals
|
|||
- Leverage Nim's macro system to produce a framework that allows
|
||||
for the development of applications that are boilerplate free.
|
||||
- Keep it small, keep it fast, keep it flexible.
|
||||
|
||||
.. |travis| image:: https://travis-ci.org/pragmagic/karax.svg?branch=master
|
||||
:target: https://travis-ci.org/pragmagic/karax
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ proc `&`*(a, b: cstring): cstring {.importcpp: "(# + #)", nodecl.}
|
|||
proc toCstr*(s: int): cstring {.importcpp: "((#)+'')", nodecl.}
|
||||
proc `&`*(s: int): cstring {.importcpp: "((#)+'')", nodecl.}
|
||||
proc `&`*(s: bool): cstring {.importcpp: "((#)+'')", nodecl.}
|
||||
proc `&`*(s: float): cstring {.importcpp: "((#)+'')", nodecl.}
|
||||
|
||||
proc `&`*(s: cstring): cstring {.importcpp: "(#)", nodecl.}
|
||||
|
||||
proc isInt*(s: cstring): bool {.asmNoStackFrame.} =
|
||||
asm """
|
||||
return s.match(/^[0-9]+$/);
|
||||
return `s`.match(/^[0-9]+$/);
|
||||
"""
|
||||
|
||||
proc parseInt*(s: cstring): int {.importcpp: "parseInt(#, 10)", nodecl.}
|
||||
|
|
|
|||
|
|
@ -47,12 +47,18 @@ proc tcall2(n, tmpContext: NimNode): NimNode =
|
|||
assert n.len == result.len
|
||||
if L > 0:
|
||||
result[L-1] = tcall2(result[L-1], tmpContext)
|
||||
of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkCaseStmt,
|
||||
nnkTryStmt, nnkFinally:
|
||||
of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkTryStmt,
|
||||
nnkFinally:
|
||||
# recurse for every child:
|
||||
result = copyNimNode(n)
|
||||
for x in n:
|
||||
result.add tcall2(x, tmpContext)
|
||||
of nnkCaseStmt:
|
||||
# recurse for children, but don't add call for case ident
|
||||
result = copyNimNode(n)
|
||||
result.add n[0]
|
||||
for i in 1 ..< n.len:
|
||||
result.add tcall2(n[i], tmpContext)
|
||||
of nnkVarSection, nnkLetSection, nnkConstSection:
|
||||
result = n
|
||||
of nnkCallKinds:
|
||||
|
|
|
|||
|
|
@ -255,3 +255,11 @@ proc applyStyle*(n: Node; s: VStyle) =
|
|||
n.style = Style()
|
||||
for x in s.mask:
|
||||
n.style.setStyle(toStyleAttrName[x], s.attrs[x])
|
||||
|
||||
import jstrutils
|
||||
|
||||
proc rgb*(r, g, b: range[0..255]): cstring =
|
||||
cstring"rgb(" & &r & cstring", " & &g & cstring", " & &b & cstring")"
|
||||
|
||||
proc rgba*(r, g, b: range[0..255], alpha: float): cstring =
|
||||
cstring"rgb(" & &r & cstring", " & &g & cstring", " & &b & cstring", " & &alpha & cstring")"
|
||||
|
|
|
|||
18
tests/compiler_tests.nim
Normal file
18
tests/compiler_tests.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
include karaxprelude
|
||||
|
||||
block:
|
||||
type
|
||||
TestEnum {.pure.} = enum
|
||||
ValA, ValB
|
||||
|
||||
var e = TestEnum.ValA
|
||||
|
||||
proc renderDom(): VNode {.used.} =
|
||||
result = buildHtml():
|
||||
tdiv():
|
||||
case e
|
||||
of TestEnum.ValA:
|
||||
tdiv: text "A"
|
||||
of TestEnum.ValB:
|
||||
tdiv: text "B"
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ proc exec(cmd: string) =
|
|||
|
||||
proc main =
|
||||
exec("nim js tests/diffDomTests.nim")
|
||||
exec("nim js tests/compiler_tests.nim")
|
||||
exec("nim js examples/todoapp/todoapp.nim")
|
||||
exec("nim js examples/scrollapp/scrollapp.nim")
|
||||
exec("nim js examples/mediaplayer/playerapp.nim")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue