LoginSignup
0
0

More than 5 years have passed since last update.

Meteorのあんちょこ꒰。・ω・`;꒱ CoffeeScript

Last updated at Posted at 2016-07-03

目的

  • Meteorを他のスクリプト言語でも書けるかな?と思ってトライ。
  • CoffeeScriptが古いっていうのは置いといてください。
  • がんがん、CoffeeScriptで書く気負いもありません。

参考

パッケージの追加

console
$ meteor add coffeescript
  • .meteor/packagesにcoffee scriptが追加される。
  • 下記を見てるとEcmascriptで書くのが良さそう。
packages
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base             # Packages every Meteor app needs to have
mobile-experience       # Packages for a great mobile UX
mongo                   # The database Meteor supports right now
blaze-html-templates    # Compile .html files into Meteor Blaze views
reactive-var            # Reactive variable for tracker
jquery                  # Helpful client-side library
tracker                 # Meteor's client-side reactive programming library

standard-minifier-css   # CSS minifier run for production mode
standard-minifier-js    # JS minifier run for production mode
es5-shim                # ECMAScript 5 compatibility for older browsers.
ecmascript              # Enable ECMAScript2015+ syntax in app code

autopublish             # Publish all data to the clients (for prototyping)
insecure                # Allow all DB writes from clients (for prototyping)
coffeescript

JavascriptからCoffeeScriptに変換

server/main.coffee
`import { Meteor } from 'meteor/meteor';`

Meteor.startup ->
  console.log "code to run on server at startup"
client/main.coffee
`import { Template } from 'meteor/templating'`
`import { ReactiveVar } from 'meteor/reactive-var'`
`import './main.html'`

Template.hello.events "click button": ->
    console.log "You pressed the button"  if typeof console isnt "undefined"
    return

チャットアプリを作成してみる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0