AppML 作成法


2 つの簡単なステップで、AppML アプリケーションを作成する方法。


1. HTML と CSS を使用してページを作成する

HTML

<!DOCTYPE html>
<html lang="ja">
<link rel="stylesheet" href="style.css">
<title>Customers</title>
<body>

<h1>Customers</h1>

<table>
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr>
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>
Try It Yourself »
Note {{ }} 括弧 は、AppML データのプレースホルダです。

CSS

body {
    font: 14px Verdana, sans-serif;
}
h1 {
    color: #996600;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    border: 1px solid grey;
    padding: 5px;
    text-align: left;
}
table tr:nth-child(odd) {
    background-color: #f1f1f1;
}
Note CSS を、自分の好きなスタイルシートと入れ替えてください。

2. AppML の追加

ページにデータを追加するために AppML を使用します:

<!DOCTYPE html>
<html lang="ja">
<title>Customers</title>
<link rel="stylesheet" href="style.css">
<script src="http://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>

<h1>Customers</h1>

<table appml-data="customers.js">
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>
Try It Yourself »

AppML の説明:

<script src="http://www.w3schools.com/appml/2.0.3/appml.js"> は、 ページに AppML を追加します。

appml-data="customers.js" は、 AppML データ (customers.js) を HTML 要素 (<table>) に接続します。

このケースでは、次の JSON ファイルを使用します: customers.js

appml-repeat="records" は、データ・オブジェクト内の各項目(レコード)に対し、 HTML 要素t (<tr>) を繰り返します。

{{ }} 括弧は、AppML データのプレースホルダです。