Skip to content

Instantly share code, notes, and snippets.

@giisyu
Last active September 11, 2016 03:05
Show Gist options
  • Save giisyu/53b18037fe33972680db38f4092f8460 to your computer and use it in GitHub Desktop.
Save giisyu/53b18037fe33972680db38f4092f8460 to your computer and use it in GitHub Desktop.
module Main exposing (..) --モジュールに名前を付ける
import Html.App exposing (programWithFlags)
main =
programWithFlags {init = init , update = update , view = view ,subscriptions = subscriptions}
init : SList -> (Model,Cmd a) ---JS側から渡される値が引数に。型を書く必要がある。
init list = {data = list } ! []
..
<script type="text/javascript", src="javascripts/App.js"> //ElmをJSコンパイルして出来たJSを読み込む。
..
var app = Elm.Main.fullscreen({.....}); ---Elm.モジュール名.起動モード(データ)
var value = [{hoge:"aaaa", huga:"bbbb"}] //サーバー側の値
router.get('/', function(req, res, next) {
res.render('index', {test:value}); //testという変数でJSオブジェクトを設定しています
});
extends layout
block content
script.
var app = Elm.Main.fullscreen( !{JSON.stringify(test).replace(/</g, '&lt;').replace(/>/g, '&gt;')} ); //-ここでtest変数をHTMLにレンダリング。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment