You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/user-guide/tutorial/index.md
+6-90Lines changed: 6 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,16 +153,12 @@ The pre-built SQL driver can be used for SQLite, although the SQLite driver can
153
153
154
154
## Specifying a Template System
155
155
156
-
In TreeFrog Framework, we can specify either Otama or ERB as a template system. We will set the TemplateSystem parameter in the _development.ini_ file.
156
+
In TreeFrog Framework, ERB is selected as the default template system. It is set in the TemplateSystem parameter of the _development.ini_ file.
157
157
158
158
```
159
159
TemplateSystem=ERB
160
-
or
161
-
TemplateSystem=Otama
162
160
```
163
161
164
-
ERB is specified by default.
165
-
166
162
## Automatic Generation of Code Created from the Table
167
163
168
164
From the command line, run the command generator (tspawn) which will generate the underlying code. The example below shows the production of controller, model, and view. The table name is specified as the command argument.
@@ -188,12 +184,8 @@ Depending on the tspawn option, only controllers or models can be generated.
188
184
189
185
### Vue.js support
190
186
191
-
In version 2 and later, it is possible to choose to generate views using [vue.js](https://vuejs.org/).
192
-
193
-
```
194
-
:
195
-
Create sources for vue.js? [y/n] y ← Enter 'y'
196
-
```
187
+
It is possible to choose to generate views using [vue.js](https://vuejs.org/).
188
+
See [Vite + Vue](/en/user-guide/view/vite+vue.html){:target="_blank"} chapter.
197
189
198
190
### Reference: Help for tspawn command
199
191
@@ -547,9 +539,9 @@ As you can see, you can use the texport method to pass data to the view (templat
547
539
548
540
## View Mechanism
549
541
550
-
Two template systems have been incorporated into TreeFrog so far. These are the proprietary system (called Otama) and ERB. As is familiar from Rails, ERB is used for embedding into HTML.
542
+
TreeFrog utilizes the ERB template system, which allows for the embedding of C++ code as it is known in Rails.
551
543
552
-
The default view that is automatically generated by the generator is an ERB file. So, let's take a look at the contents of index.erb. As you can see, the C++ code is surrounded by <% … %>. When the render method is called from the index action, the content of index.erb is returned as the response.
544
+
Let's take a look at the contents of index.erb. As you can see, the C++ code is surrounded by <% … %>. When the render method is called from the index action, the content of index.erb is returned as the response.
553
545
554
546
```
555
547
<!DOCTYPE HTML>
@@ -586,82 +578,6 @@ The default view that is automatically generated by the generator is an ERB file
586
578
</table>
587
579
```
588
580
589
-
**Another template system**
590
-
591
-
Otama is a template system that completely separates the presentation logic from the templates. The template is written in HTML and a "mark" element is inserted as the start tag of the section to be rewritten dynamically. The presentation logic file, written in C++ code, provides the logic in relation to the "mark".
592
-
593
-
The following example is a file, _index.html_, that is generated by the generator when it is specified in the Otama template system. This can include the file data, but you will see, if you open it in your browser as it is, because it uses HTML5, the design does not collapse at all without the data.
A custom attribute called 'data-tf' is used to turn on the "mark". This is a Custom Data Attribute as defined in HTML5. A string beginning with "@" is used as the value for the "mark".
629
-
630
-
Next, let's look at the index.otm corresponding to the presentation logic.<br>
631
-
The mark, which links to the associated logic, is declared in the above template, and continues in effect until a blank line is encountered. The logic is contained in the C++ part of the code.
632
-
633
-
Operators (such as == ~ =) are also used. The operators control different behaviors (for more information see the following chapters).
634
-
635
-
```c++
636
-
#include "blog.h" ← This is as it is C++ code to include the blog.h
@linkToRemove :== linkTo("Remove", urla("remove", i.id()), Tf::Post, "confirm('Are you sure?')")
657
-
```
658
-
659
-
The Otama operators, (and their combinations) are fairly simple:<br>
660
-
\~ (tilde) sets the content of marked elements to the result of the right-hand side,
661
-
\= output the HTML escape, therefore ~= sets the content of the element to the results of the right-hand side then HTML-escape, if you don't want to escape HTML, you can use ~==.
662
-
663
-
\: (colon) replaces the result of the right-hand child elements and the elements that are marked, therefore :== replaces the element without HTML escape.
664
-
665
581
### Passing Data from the Service or the Controller to the View
666
582
667
583
In order to use the exported data (objects) in the view, you need to declare its variables by the tfetch() function. For the argument, specify type of the variable and the variable name. The variables are the same state as immediately before the specified variables are exported, and can be used exactly the same way as a normal variable of C++.
@@ -678,7 +594,7 @@ View side :
678
594
tfetch(int, hoge);
679
595
```
680
596
681
-
The Otama system, generates the C++ code based on the presentation file and the template file. Internally, tmake is responsible for processing it. After that the code is compiled, with the shared library as one view, so, the operation is very fast.
597
+
To pass multiple variables to the view, simply call _texport_ on each one.
Copy file name to clipboardExpand all lines: docs/en/user-guide/view/index.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ page_id: "070.0"
5
5
6
6
## View
7
7
8
-
The role of view in a Web application is to generate an HTML document from a response. The developer creates each template for an HTML document to be embedded in a predetermined portion of the variable passed from the controller (model).
8
+
The role of a view in a web application is to generate an HTML document and return it as a response. Developers create HTML templates in which variables passed from the controller are embedded in predefined locations. These templates can also include conditional branches and loops.
9
9
10
-
There are two template systems so far adopted into the TreeFrog Framework. These are Otama and ERB. In both systems you can output the value dynamically using the template, and perform loops and conditional branching.
10
+
TreeFrog allows the use of ERB as its template system. ERB is a system (or library) that lets you write program code directly within templates, similar to what is available in Ruby. While ERB is simple and easy to understand, it has the drawback of making it harder to preview or modify web designs.
11
11
12
-
The ERB system, such as in Ruby, is used to embed the template code in the program (library). While there are benefits in that it is easy to understand as a mechanism, it is difficult to check or change the Web design.
12
+
When code written with the template system is built, it is converted into C++ code, compiled, and turned into a single shared library (dynamic link library). Since it is C++, it runs with high performance.
13
13
14
-
Otama is a template system that completely separates the presentation logic and the templates. The advantage is that checking or changing the Web Design is easy, and programmers and designers are better able to collaboration. The disadvantage is that a little more complex mechanism is required, and that there will be a slight learning cost.
14
+
By delegating the frontend to a JavaScript framework, the backend implementation can be kept minimal. TreeFrog can generate a scaffold for Vite + Vue.
15
15
16
-
Performance is the same in either. When the codes are built, the templates are compiled after it is converted to C++ code. One shared library (dynamic link library) is created, so both run faster. After that, it depends on user's description of the code.
16
+
Although a template system called Otama, which separates templates from presentation logic, was implemented, it is now deprecated.
17
17
18
18
*[To the chapter of ERB template system >>]({{ site.baseurl }}/en/user-guide/view/erb.html){:target="_blank"}
19
-
*[To the chapter of Otama template system >>]({{ site.baseurl }}/en/user-guide/view/otama-template-system.html){:target="_blank"}
19
+
*[To the chapter of Vite + Vue >>](/en/user-guide/view/vite+vue.html){:target="_blank"}
0 commit comments