3 namespace BookStack\Http\Controllers;
5 use BookStack\Entities\Repos\PageRepo;
6 use BookStack\Exceptions\NotFoundException;
7 use Illuminate\Http\Request;
9 class PageTemplateController extends Controller
14 * PageTemplateController constructor
16 public function __construct(PageRepo $pageRepo)
18 $this->pageRepo = $pageRepo;
22 * Fetch a list of templates from the system.
24 public function list(Request $request)
26 $page = $request->get('page', 1);
27 $search = $request->get('search', '');
28 $templates = $this->pageRepo->getTemplates(10, $page, $search);
31 $templates->appends(['search' => $search]);
34 return view('pages.template-manager-list', [
35 'templates' => $templates
40 * Get the content of a template.
41 * @throws NotFoundException
43 public function get(int $templateId)
45 $page = $this->pageRepo->getById($templateId);
47 if (!$page->template) {
48 throw new NotFoundException();
51 return response()->json([
52 'html' => $page->html,
53 'markdown' => $page->markdown,