mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-10 00:58:10 +00:00
Deploy to GitHub pages
This commit is contained in:
25
nimcache/runnableExamples/jsffi_examples_1.nim
Normal file
25
nimcache/runnableExamples/jsffi_examples_1.nim
Normal file
@@ -0,0 +1,25 @@
|
||||
#[
|
||||
autogenerated by docgen
|
||||
loc: /home/runner/work/Nim/Nim/lib/js/jsffi.nim(16, 1)
|
||||
rdoccmd:
|
||||
]#
|
||||
import std/assertions
|
||||
import "/home/runner/work/Nim/Nim/lib/js/jsffi.nim"
|
||||
{.line: ("/home/runner/work/Nim/Nim/lib/js/jsffi.nim", 16, 1).}:
|
||||
# Here, we are using jQuery for just a few calls and do not want to wrap the
|
||||
# whole library:
|
||||
|
||||
# import the document object and the console
|
||||
var document {.importc, nodecl.}: JsObject
|
||||
var console {.importc, nodecl.}: JsObject
|
||||
# import the "$" function
|
||||
proc jq(selector: JsObject): JsObject {.importjs: "$$(#)".}
|
||||
|
||||
# Use jQuery to make the following code run, after the document is ready.
|
||||
# This uses an experimental `.()` operator for `JsObject`, to emit
|
||||
# JavaScript calls, when no corresponding proc exists for `JsObject`.
|
||||
proc main =
|
||||
jq(document).ready(proc() =
|
||||
console.log("Hello JavaScript!")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user