Reputation: 8732
I am using the framework Play 2.0 with Java I have some html
<div>my html</div>
in a file test.html
Is there anyway I can access the html in another file (say main.html)? Maybe through some global variable
I tried to surround my html with
@variable{<div>my html</div>}
Then access it from main.html using
@variable
But this didn't work...
Any ideas?
Upvotes: 0
Views: 167
Reputation: 5951
Templates are basically functions as stated in the link that szegedi mentioned.
I think what you want is called tags
in Play. Basically you have a file with some HTML: let's say a progress bar:
@(progressPercentage : Int) // define input params for this view/function
<div class="progress progress-success progress-striped active">
<div class="bar" style="width: @progressPercentage%;">@progressPercentage%</div>
</div>
The file above is called progress.sacala.html and save in views.tags.graphs
The you can access
or call this piece of HTML by entering the following in one of your views:
@tags.graphs.progress(yourPercentageVar)
Of course you can do it without passing any variable, but I thought it would be nice to include the vars as well. Good luck!
Upvotes: 4
Reputation: 873
You should try html escaping:
@Html(test.content)
If that doesn't work, here's the doc, how to use the templating engine for what you want: Java template usecases
Upvotes: 0