Last active
September 11, 2016 03:05
-
-
Save giisyu/53b18037fe33972680db38f4092f8460 to your computer and use it in GitHub Desktop.
ElmのprogramWithFlags ref: http://qiita.com/jooex/items/166aca50f00ca03aa95d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } ! [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.. | |
<script type="text/javascript", src="javascripts/App.js"> //ElmをJSコンパイルして出来たJSを読み込む。 | |
.. | |
var app = Elm.Main.fullscreen({.....}); ---Elm.モジュール名.起動モード(データ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var value = [{hoge:"aaaa", huga:"bbbb"}] //サーバー側の値 | |
router.get('/', function(req, res, next) { | |
res.render('index', {test:value}); //testという変数でJSオブジェクトを設定しています | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends layout | |
block content | |
script. | |
var app = Elm.Main.fullscreen( !{JSON.stringify(test).replace(/</g, '<').replace(/>/g, '>')} ); //-ここでtest変数をHTMLにレンダリング。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment