GithubHelp home page GithubHelp logo

Comments (4)

geotre avatar geotre commented on June 11, 2024

You could create a separate module that you compile to js.

proc myFunc {.exportc.} =
  echo "hello"

And load that on your page so that it runs when the user clicks the link.

It may be better though to create a karax SPA instead of using it for server side templates, depending on what you are building?

from karax.

Corazone777 avatar Corazone777 commented on June 11, 2024

I'm just trying nim out, awesome language. I did what you suggested and got file.js, now im not sure how to include it inside file.nim so i can use that function on onclick = . I'm sorry I'm still noob.

from karax.

geotre avatar geotre commented on June 11, 2024

You could add this line into your karax template to load the script:

script(`type`="text/javascript", src="./file.js")

Though your webserver will need to serve it somehow.

If the webpage you are building has a lot of interactivity I would recommend building it as an SPA (compile a karax app to js) instead of using server side templates. If you need help or advice I'd suggest joining the #webdev channel on the Nim chat channels (discord/irc/matrix etc)

from karax.

geotre avatar geotre commented on June 11, 2024

I'm going to close this for now, please re-open and comment if you want to discuss this further @Corazone777

from karax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.