[TypeStyle] Generate static css + html files using TypeStyle
You can easily use TypeStyle to build static html files with encapsulated CSS. You can use this pattern to generate email and pdf template files. Since TypeStyle supports cssRaw all your css can be easily inlined into a single file making it easy to work with template rendering engines.
import {style, getStyles} from "typestyle";
import * as React from "react";
const className = style({
color: 'red',
fontSize: '30px'
});
const App = () =>
<div className={className}>
Hello World!
</div>;
import * as ReactDOMServer from 'react-dom/server';
const html = ReactDOMServer.renderToStaticMarkup(<App />);
const css = getStyles();
const renderPage = ({html, css}) => `
<html>
<header>
<style>${css}</style>
</header>
<body>
<div>${html}</div>
</body>
</html>
`;
const renderedPage = renderPage({html, css});
import * as fs from 'fs';
fs.writeFileSync(__dirname + '/index.html', renderedPage);
[TypeStyle] Generate static css + html files using TypeStyle的更多相关文章
- [TypeStyle] Load raw CSS in TypeStyle
TypeStyle tries to be an all in one CSS in JS management solution so you can always fall back to raw ...
- [TypeStyle] Style CSS pseudo elements with TypeStyle
Just like pseudo-classes, pseudo-elements are added to selectors but instead of describing a special ...
- GET /static/css/bootstrap.min.css.map HTTP/1.1" 404
解决办法:删除bootstrap.min.css文件内容最后一行/*…………*/内容即可
- Export-XLSX PowerShell generate real Excel XLSX files without Excel and COM
http://gallery.technet.microsoft.com/scriptcenter/Export-XLSX-PowerShell-f2f0c035
- Settings Django Static Files
静态文件是通过django.contrib.staticfiles来管理的. 配置Django静态文件,Djang官网静态文件配置介绍.简言之,通过以下三个步骤来配置和加载静态文件: 设置静态文件别名 ...
- Django 静态文件配置(static files)
Django version: 1.9 Python versrion: 3.5.2 这几天Django配置静态文件(本例是要加载index.css), 总是不对,最后终于试对了,这里记录下,方便以后 ...
- 【CSS】CSS3从入门到深入(复习查漏向
CSS3从入门到深入(复习查漏向 pre_section CSS:层叠样式表,决定网页表现 网页为多层结构,CSS为每一层设置样式,最后显示最上一层 CSS语句 = 选择器 + 声明块 形式 内联样式 ...
- Express细节探究(1)——app.use(express.static)
express相信是很多人用nodejs搭建服务器的首选框架,相关教程有很多,也教会了大家来如何使用.如果你想更深的了解他的细节,不妨和我一起来研究一下. 先来看一个每个人都用到的方法app.use( ...
- 前端自动化(三) 合并压缩css、压缩js、添加时间戳、打包上线操作
前端自动化(三) 合并压缩css.压缩js.添加时间戳.打包上线操作 此文在前两篇基础上对比参考,会很方便理解 gulp.task("delete",function(){ r ...
随机推荐
- Python datetime time 等时间 日期 之间的计算和相互转化
from datetime import datetime, date, timedelta, timezone from time import time, ctime, localtime, st ...
- Java中的继承和接口
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 这是个老话题,继承和接口是实现多态的两种方式,如果对象很多,其中一对一对的有共同点,建议用继承,如果 ...
- PatentTips - Enhancing the usability of virtual machines
BACKGROUND Virtualization technology enables a single host computer running a virtual machine monito ...
- [RxJS] Marbles Testings
Install: npm install — save-dev jasmine-marbles Basic example: import {cold, getTestScheduler} from ...
- [Angular] Make a chatbot with DialogFlow
Register a account on https://console.dialogflow.com/api-client/ "Creat a intent" -- you c ...
- js36---函数嵌套
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- 19,tuple多元数组
#include <iostream> #include <tuple> using namespace std; void main() { char ch = 'a'; ; ...
- Flume的可管理性
Flume的可管理性 所有agent和Collector由master统一管理,这使得系统便于维护. 多master情况,Flume利用 ZooKeeper和gossip,保证动态配置数据的一致性. ...
- pytest_多用例执行(1)
一.首先创建测试套件 # -*- coding:utf-8 -*-from __future__ import print_functionimport pytestimport allure cla ...
- 【2017 Multi-University Training Contest - Team 7】 Euler theorem
[Link]:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=765 [Description] 问你a ...