Ruby View
KDRS Search & View can be extended for advanced data manipulation and presentation. Some basic XML config is need to activate the view. We encourage the use of XML where possible, and then use Ruby views when needed. This allows for readability in the community.
Table of Contents
- Ruby View
- Make a new file for the view
- Reference the view from xml
- Minimum template
- Data
- Columns
- Html
- Ruby
- CSS
Make a new file for the view
In the templates/your_system/
directory on your host, create a new file for your view. It must start with underscore. Use lowercase. The html.erb extention will make sure that the Ruby server will process the file first, then the html engine.
Reference the view from xml
The program flow will be redirected to this view. You will be in control of the presentation.
Minimum template
Note
Use ‘=’ to output Ruby on screen`
This view template will generate the same view as the default template. The difference is that you can manipulate the data as needed, and change the presentation with new styling, titles, extra text, tables etc. Maybe you want some different layout on print. This and more you can change from here.
Data
The data from xml will be available to the view in the @docs
variable. If you need more data from other tables, you can fetch those here. See the examples for how this is done.
Columns
Select the fields you want to show as columns in the view
Html
You can write plain html in this file
Ruby
You can write plain Ruby in this file, as long as you use the brackets.
Ruby can be used to edit the data, or write HTML code, like in this example:
CSS
You can style your data with css, or adjust margins
Note: It is technically possible use Javascript for advanced presentation. However - we encourage the use of Ruby whenever possible for human readability and code sharing.