Skip to content

Commit

Permalink
wip creating maven
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Huang authored and AndrewYHuang committed Aug 8, 2024
1 parent 9320147 commit c262c12
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 16 deletions.
76 changes: 76 additions & 0 deletions .vitepress/sidebars/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,81 @@ export const java = [
},
{ text: 'Data types', link: '/java/data-types' }
]
},
{
text: 'Data and iteration',
collapsed: true,
items: [
{
text: 'Arrays',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
},
{
text: 'Strings',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
},
{
text: 'Loops',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
},

{
text: 'Objects',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
}
]
},

{
text: 'Object oriented programming',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' },
{
text: 'Design patterns',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
}
]
},

{
text: 'Testing',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
},

{
text: 'Building projects',
collapsed: true,
items: [
{ text: 'Creating a Maven project', link: '/java/qq' },
{ text: 'Making a CLI', link: '/java/qq' },
{ text: 'Handling Errors', link: '/java/qq' },
]
},

{
text: 'Asynchronous code',
collapsed: true,
items: [
{ text: 'qq', link: '/java/qq' }
]
}
]
4 changes: 4 additions & 0 deletions src/java/maven.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Creating a Maven project

##

44 changes: 28 additions & 16 deletions src/javalin/template-partials.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Template partials

<Vimeo id="936176254" />

## The problem

Many pages in a website might share the same content. For example, our views
might look like this (the repeated content has been highlighted):

::: code-group

```html{1-9,12-13} [index.ejs]
```html{1-9,12-13} [index.jte]
@import bleeter.models.Page
@param Page page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bleeter | <%= title %></title>
<title>Bleeter | ${page.title}</title>
</head>
<body>
Expand All @@ -25,43 +26,54 @@ might look like this (the repeated content has been highlighted):
</html>
```

```html{1-9,20-21} [bleets.ejs]
```html{1-9,20-21} [bleets.jte]
@import java.util.List
@import bleeter.models.Page
@import bleeter.models.Bleet
@param Page page
@param List<Bleet> bleets
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bleeter | <%= title %></title>
<title>Bleeter | ${page.title}</title>
</head>
<body>
<h1>Bleets</h1>
<ol>
<% for (let bleet of bleets) { %>
@for(var bleet : bleets)
<!-- use bleet -->
<li>
<%= bleet.content.slice(0, 10) + '...' %>
<a href="<%= `/bleets/${bleet.id}` %>">Read more</a>
${bleet.content.substring(0, 10)}...
<a href="/bleets/${bleet.id}">Read more</a>
</li>
<% } %>
@endfor
</ol>
</body>
</html>
```

```html{1-9,13-14} [bleet.ejs]
```html{1-9,13-14} [bleet.jte]
@import bleeter.models.Page
@import bleeter.models.Bleet
@param Page page
@param Bleet bleet
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bleeter | <%= title %></title>
<title>Bleeter | ${page.title}</title>
</head>
<body>
<h1>A bleet</h1>
<p><%= bleet.content %></p>
<p><%= bleet.createdAt %></p>
<p>${bleet.content}</p>
<p>${bleet.createdAt}</p>
</body>
</html>
```
Expand All @@ -72,14 +84,14 @@ This is a problem, because if we need to make a change to the shared parts of
each view, we need to update each view individually, which is extra work and an
opportunity for mistakes.

## Creating partials
## Template calls

We can create partial templates and use them in our views.

The directory structure might look like this:

```txt
views/
templates/
├── bleet.ejs
├── bleets.ejs
├── index.ejs
Expand Down

0 comments on commit c262c12

Please sign in to comment.