Giter Club home page Giter Club logo

cljs-apps-script's Introduction

cljs-apps-script

Example usage of ClojureScript in Google Apps Script.

Setup and Usage

  1. Clone this repo.
  2. Write your cljs code like normal in src/*.
  3. For functions you want to expose to the outside world, ^:export their symbols (see src/cljs_apps_script/core.cljs for examples).
  4. To run/test your code locally, build with source scripts/build (run from the project root) and open index.html in your browser. To auto-rebuild on changes to src/*, do source scripts/watch.
  5. To use your code in Google Apps Script, first build it with source scripts/release, then copy-and-paste the compiled JavaScript from release/cljs_apps_script_<current-project-version>.js into your Google Apps script.

Note on scripts/release

I've tweaked the scripts/release.clj to do the following:

  1. Add the current project version (from project.clj) as a comment at the top the compiled JS โ€“ that way you can keep track of what version is in Google Apps Script.
  2. Add the release version to the filename of the compiled JS, like so: release/cljs_apps_script_<current-project-version>.js

If you don't update your project version between builds it will overwrite the previous build since the version is in the build filename. Also, since the release version number is baked into filename, you'll need to change the version number in index_release.html to test the most recent version.

Using ^:exported Functions

Exported functions can be found at <namespace>.<namespace-qualifier>.<function-name>, e.g. cljs_apps_script.core.say_hello(). The - (dashes) in any function names are replaced with _ (underscores).

If you wanted to, say, use an ^:exported function as a custom function in Google Apps Script, include something like:

/** @customfunction */
function sayHello(x) {
  return cljs_apps_script.core.say_hello(x);
}

at the bottom of your code in Google Apps Script.

To Do

Attribution

This Leiningen project was initially created with the Mies template and so I got all the scripts from there and tweaked them to my use.

License

MIT (see LICENSE)

cljs-apps-script's People

Contributors

whitecoop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thearthur

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.