mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-05 09:00:24 +00:00
updated java doc in templating
This commit is contained in:
@@ -33,7 +33,6 @@ public class TemplateServiceBean implements TemplateService {
|
||||
@Autowired
|
||||
private Gson gson;
|
||||
|
||||
|
||||
/**
|
||||
* Formats the passed passed count with the embed used for formatting pages.
|
||||
* @param count The index of the page you want formated.
|
||||
@@ -169,11 +168,21 @@ public class TemplateServiceBean implements TemplateService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a simple template identified by key without any model. This will cause exceptions in case there are references to a model in the provided template.
|
||||
* @param key The key of the template to be rendered
|
||||
* @return The rendered template as a string
|
||||
*/
|
||||
@Override
|
||||
public String renderSimpleTemplate(String key) {
|
||||
return renderTemplate(key, new Object());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the {@link Templatable} object using the template key and the model and returns it as a string.
|
||||
* @param templatable The {@link Templatable} object to be rendered
|
||||
* @return The rendered {@link Templatable} as a string
|
||||
*/
|
||||
@Override
|
||||
public String renderTemplatable(Templatable templatable) {
|
||||
return renderTemplate(templatable.getTemplateName(), templatable.getTemplateModel());
|
||||
|
||||
@@ -20,16 +20,32 @@ public class TemplateManagementServiceBean implements TemplateManagementService
|
||||
@Autowired
|
||||
private TemplateRepository repository;
|
||||
|
||||
/**
|
||||
* Returns the template from the database by key
|
||||
* @param key They template key to search for
|
||||
* @return An {@link Optional} containing the {@link Template} if any was found.
|
||||
*/
|
||||
@Override
|
||||
public Optional<Template> getTemplateByKey(String key) {
|
||||
return repository.findById(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the template identified by the key exists in the database
|
||||
* @param key They key of the template to search for
|
||||
* @return Whether or not the template exists in the database
|
||||
*/
|
||||
@Override
|
||||
public boolean templateExists(String key) {
|
||||
return repository.existsById(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Template} object and stores it in the database. Returns the newly created object.
|
||||
* @param key They key of the template to create.
|
||||
* @param content The content the template should have
|
||||
* @return The {@link Template} which was created
|
||||
*/
|
||||
@Override
|
||||
public Template createTemplate(String key, String content) {
|
||||
Template build = Template.builder().key(key).content(content).lastModified(Instant.now()).build();
|
||||
|
||||
Reference in New Issue
Block a user