Уведомления

Группа в Telegram: @pythonsu

#1 Ноя. 7, 2017 11:04:44

zikfriddi
Зарегистрирован: 2016-07-29
Сообщения: 28
Репутация: +  0  -
Профиль   Адрес электронной почты  

Форматирование строк

Доброго всем дня.
Есть файл html с таким содержимым:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no">
		<style type="text/css" media="screen">
			.ExternalClass * {line-height:100%}
			@media only screen and (max-width:480px) {
				*[id=email-penrose-conteneur] {width:100% !important;}
				table[class=resp-full-table] {width:100% !important; clear:both;}
				td[class=resp-full-td] {width:100% !important; clear:both;}
				td[class=resp-full-td-center] {width:100%!important; clear:both; text-align: center !important;}
				.my-clear{padding: 10px 10px !important;}
				img[class=email-penrose-img-header] {width:100% !important; max-width:340px !important;}
				a[class=resp-punchline] {font-size:30px !important;}
				hr[class=resp-hr-center] {text-align: center !important; margin-left:auto !important; margin-right:auto !important;}
				td[class=logo_header]{ text-align:center !important;}
				td[class=back-header]{background-image: url(http://ipcons2.vrn.ru/updateserver/img/new/10_3_190-139-101_.jpg); background-size: cover !important;}
				[class=my-td]{border:none !important;}
			}
		</style>
	</head>
	<body bgcolor="#ecf0f1">
{NAME}
		<div align="center" style="background-color:#ecf0f1;">
			<table id="email-penrose-conteneur" width="660" align="center" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
				<tr>
					<td>
						<table width="660" class="resp-full-table" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
							<tr>
								<td class="logo_header" width="100%" style="text-align:left; padding:20px 0px;">
									<a href=""><svg height="55px"><image xlink:href="http://ipcons2.vrn.ru/updateserver/img/new/logo.svg" src="http://ipcons2.vrn.ru/updateserver/img/new/logo.png" width="250px"/></svg></a>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
....
В этом файле необходимо подставить значение переменной NAME. Раньше все это делал с помощью .format(name=значение), но теперь появилась шапка с описанием стилей, из-за которой появляется ошибка. Какие варианты обхода есть? Я пока придумал только разделить файл на 2, а после подстановки соединять их.

Офлайн

#2 Ноя. 7, 2017 11:38:25

FishHook
От:
Зарегистрирован: 2011-01-08
Сообщения: 8312
Репутация: +  568  -
Профиль   Отправить e-mail  

Форматирование строк

zikfriddi
используйте шаблонизаторы, например http://jinja.pocoo.org/docs/2.9/



Офлайн

#3 Ноя. 8, 2017 07:28:24

zikfriddi
Зарегистрирован: 2016-07-29
Сообщения: 28
Репутация: +  0  -
Профиль   Адрес электронной почты  

Форматирование строк

Да, спасибо.

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version